sd-journal: drop unnecessary temporal variable 'k'

No functional change, just refactoring.
This commit is contained in:
Yu Watanabe
2024-08-15 04:43:32 +09:00
parent 24ce1703c4
commit 3fc1e4f63a
+15 -25
View File
@@ -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;