summaryrefslogtreecommitdiff
path: root/src/journal
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2020-09-08 11:58:29 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2020-09-08 12:14:05 +0200
commit90e74a66e663f1776457d599cb7d5ce44785a56c (patch)
tree16ce28594b8dc475e37df9a3b80accb96e748efa /src/journal
parent12375b95ddcb7dbbcbc5969b87822d39115d8acf (diff)
downloadsystemd-90e74a66e663f1776457d599cb7d5ce44785a56c.tar.gz
tree-wide: define iterator inside of the macro
Diffstat (limited to 'src/journal')
-rw-r--r--src/journal/catalog.c3
-rw-r--r--src/journal/journalctl.c15
-rw-r--r--src/journal/journald-server.c12
-rw-r--r--src/journal/journald-stream.c3
-rw-r--r--src/journal/mmap-cache.c5
-rw-r--r--src/journal/sd-journal.c35
-rw-r--r--src/journal/test-catalog.c9
7 files changed, 28 insertions, 54 deletions
diff --git a/src/journal/catalog.c b/src/journal/catalog.c
index b2589271ca..b0416da0c6 100644
--- a/src/journal/catalog.c
+++ b/src/journal/catalog.c
@@ -450,7 +450,6 @@ int catalog_update(const char* database, const char* root, const char* const* di
ssize_t offset;
char *payload;
CatalogItem *i;
- Iterator j;
unsigned n;
int r;
int64_t sz;
@@ -482,7 +481,7 @@ int catalog_update(const char* database, const char* root, const char* const* di
return log_oom();
n = 0;
- ORDERED_HASHMAP_FOREACH_KEY(payload, i, h, j) {
+ ORDERED_HASHMAP_FOREACH_KEY(payload, i, h) {
log_debug("Found " SD_ID128_FORMAT_STR ", language %s",
SD_ID128_FORMAT_VAL(i->id),
isempty(i->language) ? "C" : i->language);
diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
index 9d0048b8bc..52e204ee11 100644
--- a/src/journal/journalctl.c
+++ b/src/journal/journalctl.c
@@ -1644,14 +1644,13 @@ static int add_units(sd_journal *j) {
if (!strv_isempty(patterns)) {
_cleanup_set_free_free_ Set *units = NULL;
- Iterator it;
char *u;
r = get_possible_units(j, SYSTEM_UNITS, patterns, &units);
if (r < 0)
return r;
- SET_FOREACH(u, units, it) {
+ SET_FOREACH(u, units) {
r = add_matches_for_unit(j, u);
if (r < 0)
return r;
@@ -1689,14 +1688,13 @@ static int add_units(sd_journal *j) {
if (!strv_isempty(patterns)) {
_cleanup_set_free_free_ Set *units = NULL;
- Iterator it;
char *u;
r = get_possible_units(j, USER_UNITS, patterns, &units);
if (r < 0)
return r;
- SET_FOREACH(u, units, it) {
+ SET_FOREACH(u, units) {
r = add_matches_for_user_unit(j, u, getuid());
if (r < 0)
return r;
@@ -1745,10 +1743,9 @@ static int add_priorities(sd_journal *j) {
static int add_facilities(sd_journal *j) {
void *p;
- Iterator it;
int r;
- SET_FOREACH(p, arg_facilities, it) {
+ SET_FOREACH(p, arg_facilities) {
char match[STRLEN("SYSLOG_FACILITY=") + DECIMAL_STR_MAX(int)];
xsprintf(match, "SYSLOG_FACILITY=%d", PTR_TO_INT(p));
@@ -1960,14 +1957,13 @@ static int setup_keys(void) {
static int verify(sd_journal *j) {
int r = 0;
- Iterator i;
JournalFile *f;
assert(j);
log_show_color(true);
- ORDERED_HASHMAP_FOREACH(f, j->files, i) {
+ ORDERED_HASHMAP_FOREACH(f, j->files) {
int k;
usec_t first = 0, validated = 0, last = 0;
@@ -2327,9 +2323,8 @@ int main(int argc, char *argv[]) {
case ACTION_VACUUM: {
Directory *d;
- Iterator i;
- HASHMAP_FOREACH(d, j->directories_by_path, i) {
+ HASHMAP_FOREACH(d, j->directories_by_path) {
int q;
q = journal_directory_vacuum(d->path, arg_vacuum_size, arg_vacuum_n_files, arg_vacuum_time, NULL, !arg_quiet);
diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c
index 6df43085ec..105aefdd6e 100644
--- a/src/journal/journald-server.c
+++ b/src/journal/journald-server.c
@@ -473,10 +473,9 @@ static int do_rotate(
static void server_process_deferred_closes(Server *s) {
JournalFile *f;
- Iterator i;
/* Perform any deferred closes which aren't still offlining. */
- SET_FOREACH(f, s->deferred_closes, i) {
+ SET_FOREACH(f, s->deferred_closes) {
if (journal_file_is_offlining(f))
continue;
@@ -609,7 +608,6 @@ static int vacuum_offline_user_journals(Server *s) {
void server_rotate(Server *s) {
JournalFile *f;
- Iterator i;
void *k;
int r;
@@ -620,7 +618,7 @@ void server_rotate(Server *s) {
(void) do_rotate(s, &s->system_journal, "system", s->seal, 0);
/* Then, rotate all user journals we have open (keeping them open) */
- ORDERED_HASHMAP_FOREACH_KEY(f, k, s->user_journals, i) {
+ ORDERED_HASHMAP_FOREACH_KEY(f, k, s->user_journals) {
r = do_rotate(s, &f, "user", s->seal, PTR_TO_UID(k));
if (r >= 0)
ordered_hashmap_replace(s->user_journals, k, f);
@@ -639,7 +637,6 @@ void server_rotate(Server *s) {
void server_sync(Server *s) {
JournalFile *f;
- Iterator i;
int r;
if (s->system_journal) {
@@ -648,7 +645,7 @@ void server_sync(Server *s) {
log_warning_errno(r, "Failed to sync system journal, ignoring: %m");
}
- ORDERED_HASHMAP_FOREACH(f, s->user_journals, i) {
+ ORDERED_HASHMAP_FOREACH(f, s->user_journals) {
r = journal_file_set_offline(f, false);
if (r < 0)
log_warning_errno(r, "Failed to sync user journal, ignoring: %m");
@@ -2433,7 +2430,6 @@ int server_init(Server *s, const char *namespace) {
void server_maybe_append_tags(Server *s) {
#if HAVE_GCRYPT
JournalFile *f;
- Iterator i;
usec_t n;
n = now(CLOCK_REALTIME);
@@ -2441,7 +2437,7 @@ void server_maybe_append_tags(Server *s) {
if (s->system_journal)
journal_file_maybe_append_tag(s->system_journal, n);
- ORDERED_HASHMAP_FOREACH(f, s->user_journals, i)
+ ORDERED_HASHMAP_FOREACH(f, s->user_journals)
journal_file_maybe_append_tag(f, n);
#endif
}
diff --git a/src/journal/journald-stream.c b/src/journal/journald-stream.c
index 241e2572e6..b1c35a1af2 100644
--- a/src/journal/journald-stream.c
+++ b/src/journal/journald-stream.c
@@ -834,13 +834,12 @@ int server_restore_streams(Server *s, FDSet *fds) {
FOREACH_DIRENT(de, d, goto fail) {
unsigned long st_dev, st_ino;
bool found = false;
- Iterator i;
int fd;
if (sscanf(de->d_name, "%lu:%lu", &st_dev, &st_ino) != 2)
continue;
- FDSET_FOREACH(fd, fds, i) {
+ FDSET_FOREACH(fd, fds) {
struct stat st;
if (fstat(fd, &st) < 0)
diff --git a/src/journal/mmap-cache.c b/src/journal/mmap-cache.c
index 9eb3e1a626..f627630c9c 100644
--- a/src/journal/mmap-cache.c
+++ b/src/journal/mmap-cache.c
@@ -552,7 +552,6 @@ unsigned mmap_cache_get_missed(MMapCache *m) {
static void mmap_cache_process_sigbus(MMapCache *m) {
bool found = false;
MMapFileDescriptor *f;
- Iterator i;
int r;
assert(m);
@@ -572,7 +571,7 @@ static void mmap_cache_process_sigbus(MMapCache *m) {
}
ours = false;
- HASHMAP_FOREACH(f, m->fds, i) {
+ HASHMAP_FOREACH(f, m->fds) {
Window *w;
LIST_FOREACH(by_fd, w, f->windows) {
@@ -601,7 +600,7 @@ static void mmap_cache_process_sigbus(MMapCache *m) {
if (_likely_(!found))
return;
- HASHMAP_FOREACH(f, m->fds, i) {
+ HASHMAP_FOREACH(f, m->fds) {
Window *w;
if (!f->sigbus)
diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c
index 2023cc0c01..234e81445b 100644
--- a/src/journal/sd-journal.c
+++ b/src/journal/sd-journal.c
@@ -105,7 +105,6 @@ static int journal_put_error(sd_journal *j, int r, const char *path) {
}
static void detach_location(sd_journal *j) {
- Iterator i;
JournalFile *f;
assert(j);
@@ -113,7 +112,7 @@ static void detach_location(sd_journal *j) {
j->current_file = NULL;
j->current_field = 0;
- ORDERED_HASHMAP_FOREACH(f, j->files, i)
+ ORDERED_HASHMAP_FOREACH(f, j->files)
journal_file_reset_location(f);
}
@@ -1859,7 +1858,6 @@ static int add_search_paths(sd_journal *j) {
}
static int add_current_paths(sd_journal *j) {
- Iterator i;
JournalFile *f;
assert(j);
@@ -1868,7 +1866,7 @@ static int add_current_paths(sd_journal *j) {
/* Simply adds all directories for files we have open as directories. We don't expect errors here, so we
* treat them as fatal. */
- ORDERED_HASHMAP_FOREACH(f, j->files, i) {
+ ORDERED_HASHMAP_FOREACH(f, j->files) {
_cleanup_free_ char *dir;
int r;
@@ -2103,7 +2101,6 @@ _public_ int sd_journal_open_directory_fd(sd_journal **ret, int fd, int flags) {
}
_public_ int sd_journal_open_files_fd(sd_journal **ret, int fds[], unsigned n_fds, int flags) {
- Iterator iterator;
JournalFile *f;
_cleanup_(sd_journal_closep) sd_journal *j = NULL;
unsigned i;
@@ -2148,7 +2145,7 @@ _public_ int sd_journal_open_files_fd(sd_journal **ret, int fds[], unsigned n_fd
fail:
/* If we fail, make sure we don't take possession of the files we managed to make use of successfully, and they
* remain open */
- ORDERED_HASHMAP_FOREACH(f, j->files, iterator)
+ ORDERED_HASHMAP_FOREACH(f, j->files)
f->close_fd = false;
return r;
@@ -2566,7 +2563,6 @@ _public_ int sd_journal_get_timeout(sd_journal *j, uint64_t *timeout_usec) {
static void process_q_overflow(sd_journal *j) {
JournalFile *f;
Directory *m;
- Iterator i;
assert(j);
@@ -2580,7 +2576,7 @@ static void process_q_overflow(sd_journal *j) {
j->generation++;
(void) reiterate_all_paths(j);
- ORDERED_HASHMAP_FOREACH(f, j->files, i) {
+ ORDERED_HASHMAP_FOREACH(f, j->files) {
if (f->last_seen_generation == j->generation)
continue;
@@ -2589,7 +2585,7 @@ static void process_q_overflow(sd_journal *j) {
remove_file_real(j, f);
}
- HASHMAP_FOREACH(m, j->directories_by_path, i) {
+ HASHMAP_FOREACH(m, j->directories_by_path) {
if (m->last_seen_generation == j->generation)
continue;
@@ -2704,7 +2700,6 @@ _public_ int sd_journal_wait(sd_journal *j, uint64_t timeout_usec) {
assert_return(!journal_pid_changed(j), -ECHILD);
if (j->inotify_fd < 0) {
- Iterator i;
JournalFile *f;
/* This is the first invocation, hence create the
@@ -2715,7 +2710,7 @@ _public_ int sd_journal_wait(sd_journal *j, uint64_t timeout_usec) {
/* Server might have done some vacuuming while we weren't watching.
Get rid of the deleted files now so they don't stay around indefinitely. */
- ORDERED_HASHMAP_FOREACH(f, j->files, i) {
+ ORDERED_HASHMAP_FOREACH(f, j->files) {
r = journal_file_fstat(f);
if (r == -EIDRM)
remove_file_real(j, f);
@@ -2757,7 +2752,6 @@ _public_ int sd_journal_wait(sd_journal *j, uint64_t timeout_usec) {
}
_public_ int sd_journal_get_cutoff_realtime_usec(sd_journal *j, uint64_t *from, uint64_t *to) {
- Iterator i;
JournalFile *f;
bool first = true;
uint64_t fmin = 0, tmax = 0;
@@ -2768,7 +2762,7 @@ _public_ int sd_journal_get_cutoff_realtime_usec(sd_journal *j, uint64_t *from,
assert_return(from || to, -EINVAL);
assert_return(from != to, -EINVAL);
- ORDERED_HASHMAP_FOREACH(f, j->files, i) {
+ ORDERED_HASHMAP_FOREACH(f, j->files) {
usec_t fr, t;
r = journal_file_get_cutoff_realtime_usec(f, &fr, &t);
@@ -2798,7 +2792,6 @@ _public_ int sd_journal_get_cutoff_realtime_usec(sd_journal *j, uint64_t *from,
}
_public_ int sd_journal_get_cutoff_monotonic_usec(sd_journal *j, sd_id128_t boot_id, uint64_t *from, uint64_t *to) {
- Iterator i;
JournalFile *f;
bool found = false;
int r;
@@ -2808,7 +2801,7 @@ _public_ int sd_journal_get_cutoff_monotonic_usec(sd_journal *j, sd_id128_t boot
assert_return(from || to, -EINVAL);
assert_return(from != to, -EINVAL);
- ORDERED_HASHMAP_FOREACH(f, j->files, i) {
+ ORDERED_HASHMAP_FOREACH(f, j->files) {
usec_t fr, t;
r = journal_file_get_cutoff_monotonic_usec(f, boot_id, &fr, &t);
@@ -2837,13 +2830,12 @@ _public_ int sd_journal_get_cutoff_monotonic_usec(sd_journal *j, sd_id128_t boot
}
void journal_print_header(sd_journal *j) {
- Iterator i;
JournalFile *f;
bool newline = false;
assert(j);
- ORDERED_HASHMAP_FOREACH(f, j->files, i) {
+ ORDERED_HASHMAP_FOREACH(f, j->files) {
if (newline)
putchar('\n');
else
@@ -2854,7 +2846,6 @@ void journal_print_header(sd_journal *j) {
}
_public_ int sd_journal_get_usage(sd_journal *j, uint64_t *bytes) {
- Iterator i;
JournalFile *f;
uint64_t sum = 0;
@@ -2862,7 +2853,7 @@ _public_ int sd_journal_get_usage(sd_journal *j, uint64_t *bytes) {
assert_return(!journal_pid_changed(j), -ECHILD);
assert_return(bytes, -EINVAL);
- ORDERED_HASHMAP_FOREACH(f, j->files, i) {
+ ORDERED_HASHMAP_FOREACH(f, j->files) {
struct stat st;
if (fstat(f->fd, &st) < 0)
@@ -2920,7 +2911,6 @@ _public_ int sd_journal_enumerate_unique(sd_journal *j, const void **data, size_
for (;;) {
JournalFile *of;
- Iterator i;
Object *o;
const void *odata;
size_t ol;
@@ -2988,7 +2978,7 @@ _public_ int sd_journal_enumerate_unique(sd_journal *j, const void **data, size_
* object by checking if it exists in the earlier
* traversed files. */
found = false;
- ORDERED_HASHMAP_FOREACH(of, j->files, i) {
+ ORDERED_HASHMAP_FOREACH(of, j->files) {
if (of == j->unique_file)
break;
@@ -3060,7 +3050,6 @@ _public_ int sd_journal_enumerate_fields(sd_journal *j, const char **field) {
for (;;) {
JournalFile *f, *of;
- Iterator i;
uint64_t m;
Object *o;
size_t sz;
@@ -3137,7 +3126,7 @@ _public_ int sd_journal_enumerate_fields(sd_journal *j, const char **field) {
/* Let's see if we already returned this field name before. */
found = false;
- ORDERED_HASHMAP_FOREACH(of, j->files, i) {
+ ORDERED_HASHMAP_FOREACH(of, j->files) {
if (of == f)
break;
diff --git a/src/journal/test-catalog.c b/src/journal/test-catalog.c
index 158847f3ea..0f1447af28 100644
--- a/src/journal/test-catalog.c
+++ b/src/journal/test-catalog.c
@@ -65,7 +65,6 @@ static void test_catalog_import_badid(void) {
static void test_catalog_import_one(void) {
_cleanup_ordered_hashmap_free_free_free_ OrderedHashmap *h = NULL;
char *payload;
- Iterator j;
const char *input =
"-- 0027229ca0644181a76c4e92458afaff dededededededededededededededed\n" \
@@ -80,7 +79,7 @@ static void test_catalog_import_one(void) {
h = test_import(input, -1, 0);
assert_se(ordered_hashmap_size(h) == 1);
- ORDERED_HASHMAP_FOREACH(payload, h, j) {
+ ORDERED_HASHMAP_FOREACH(payload, h) {
printf("expect: %s\n", expect);
printf("actual: %s\n", payload);
assert_se(streq(expect, payload));
@@ -90,7 +89,6 @@ static void test_catalog_import_one(void) {
static void test_catalog_import_merge(void) {
_cleanup_ordered_hashmap_free_free_free_ OrderedHashmap *h = NULL;
char *payload;
- Iterator j;
const char *input =
"-- 0027229ca0644181a76c4e92458afaff dededededededededededededededed\n" \
@@ -116,14 +114,13 @@ static void test_catalog_import_merge(void) {
h = test_import(input, -1, 0);
assert_se(ordered_hashmap_size(h) == 1);
- ORDERED_HASHMAP_FOREACH(payload, h, j)
+ ORDERED_HASHMAP_FOREACH(payload, h)
assert_se(streq(combined, payload));
}
static void test_catalog_import_merge_no_body(void) {
_cleanup_ordered_hashmap_free_free_free_ OrderedHashmap *h = NULL;
char *payload;
- Iterator j;
const char *input =
"-- 0027229ca0644181a76c4e92458afaff dededededededededededededededed\n" \
@@ -148,7 +145,7 @@ static void test_catalog_import_merge_no_body(void) {
h = test_import(input, -1, 0);
assert_se(ordered_hashmap_size(h) == 1);
- ORDERED_HASHMAP_FOREACH(payload, h, j)
+ ORDERED_HASHMAP_FOREACH(payload, h)
assert_se(streq(combined, payload));
}