]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-journal: merge two bump_entry_array() calls
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 26 Sep 2023 16:29:11 +0000 (01:29 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 30 Sep 2023 11:10:15 +0000 (20:10 +0900)
No functional changes, just refactoring.

src/libsystemd/sd-journal/journal-file.c

index 22de80bac0f5b1b8e2eafc603953d78addc8505a..5371c6d79bd205a15fe9252fe2e3a67d98c2c6b9 100644 (file)
@@ -2752,7 +2752,7 @@ static int generic_array_get(
 
         uint64_t a, t = 0, k;
         ChainCacheItem *ci;
-        Object *o;
+        Object *o = NULL;
         int r;
 
         assert(f);
@@ -2781,12 +2781,7 @@ static int generic_array_get(
                         /* If there's corruption and we're going upwards, move back to the previous entry
                          * array and start iterating entries from there. */
 
-                        r = bump_entry_array(f, NULL, a, first, DIRECTION_UP, &a);
-                        if (r <= 0)
-                                return r;
-
                         i = UINT64_MAX;
-
                         break;
                 }
                 if (r < 0)
@@ -2808,6 +2803,10 @@ static int generic_array_get(
                 /* In the first iteration of the while loop, we reuse i, k and o from the previous while
                  * loop. */
                 if (i == UINT64_MAX) {
+                        r = bump_entry_array(f, o, a, first, direction, &a);
+                        if (r <= 0)
+                                return r;
+
                         r = journal_file_move_to_object(f, OBJECT_ENTRY_ARRAY, a, &o);
                         if (r < 0)
                                 return r;
@@ -2843,10 +2842,6 @@ static int generic_array_get(
 
                 } while (bump_array_index(&i, direction, k) > 0);
 
-                r = bump_entry_array(f, o, a, first, direction, &a);
-                if (r <= 0)
-                        return r;
-
                 t += k;
                 i = UINT64_MAX;
         }