diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2024-08-06 04:09:10 +0200 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2024-08-14 21:43:32 +0200 |
commit | 3fc1e4f63a38d04052b65eaa770d24acbf1d8864 (patch) | |
tree | 55a7ab969cd60cef29e0577c7ef11ce04b3978ff /src/libsystemd/sd-journal | |
parent | sd-journal: add trailing comma (diff) | |
download | systemd-3fc1e4f63a38d04052b65eaa770d24acbf1d8864.tar.xz systemd-3fc1e4f63a38d04052b65eaa770d24acbf1d8864.zip |
sd-journal: drop unnecessary temporal variable 'k'
No functional change, just refactoring.
Diffstat (limited to 'src/libsystemd/sd-journal')
-rw-r--r-- | src/libsystemd/sd-journal/sd-journal.c | 40 |
1 files changed, 15 insertions, 25 deletions
diff --git a/src/libsystemd/sd-journal/sd-journal.c b/src/libsystemd/sd-journal/sd-journal.c index 1bb0a5aabe..6eac5da5b9 100644 --- a/src/libsystemd/sd-journal/sd-journal.c +++ b/src/libsystemd/sd-journal/sd-journal.c @@ -62,7 +62,6 @@ static void journal_file_unlink_newest_by_boot_id(sd_journal *j, JournalFile *f) static int journal_put_error(sd_journal *j, int r, const char *path) { _cleanup_free_ char *copy = NULL; - int k; /* Memorize an error we encountered, and store which * file/directory it was generated from. Note that we store @@ -84,13 +83,11 @@ static int journal_put_error(sd_journal *j, int r, const char *path) { return -ENOMEM; } - k = hashmap_ensure_put(&j->errors, NULL, INT_TO_PTR(r), copy); - if (k < 0) { - if (k == -EEXIST) - return 0; - - return k; - } + r = hashmap_ensure_put(&j->errors, NULL, INT_TO_PTR(r), copy); + if (r == -EEXIST) + return 0; + if (r < 0) + return r; TAKE_PTR(copy); return 0; @@ -1066,11 +1063,8 @@ static int next_beyond_location(sd_journal *j, JournalFile *f, direction_t direc bool found; if (j->current_location.type == LOCATION_DISCRETE) { - int k; - - k = compare_with_location(j, f, &j->current_location, j->current_file); - - found = direction == DIRECTION_DOWN ? k > 0 : k < 0; + r = compare_with_location(j, f, &j->current_location, j->current_file); + found = direction == DIRECTION_DOWN ? r > 0 : r < 0; } else found = true; @@ -1164,11 +1158,8 @@ static int real_journal_next(sd_journal *j, direction_t direction) { if (!new_file) found = true; else { - int k; - - k = compare_locations(j, f, new_file); - - found = direction == DIRECTION_DOWN ? k < 0 : k > 0; + r = compare_locations(j, f, new_file); + found = direction == DIRECTION_DOWN ? r < 0 : r > 0; } if (found) @@ -1395,7 +1386,6 @@ _public_ int sd_journal_test_cursor(sd_journal *j, const char *cursor) { _cleanup_free_ char *item = NULL; unsigned long long ll; sd_id128_t id; - int k = 0; r = extract_first_word(&cursor, &item, ";", EXTRACT_DONT_COALESCE_SEPARATORS); if (r < 0) @@ -1410,9 +1400,9 @@ _public_ int sd_journal_test_cursor(sd_journal *j, const char *cursor) { switch (item[0]) { case 's': - k = sd_id128_from_string(item+2, &id); - if (k < 0) - return k; + r = sd_id128_from_string(item+2, &id); + if (r < 0) + return r; if (!sd_id128_equal(id, j->current_file->header->seqnum_id)) return 0; break; @@ -1425,9 +1415,9 @@ _public_ int sd_journal_test_cursor(sd_journal *j, const char *cursor) { break; case 'b': - k = sd_id128_from_string(item+2, &id); - if (k < 0) - return k; + r = sd_id128_from_string(item+2, &id); + if (r < 0) + return r; if (!sd_id128_equal(id, o->entry.boot_id)) return 0; break; |