]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
journal: Only move to object if requested
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 20 Apr 2022 17:52:13 +0000 (19:52 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 20 Apr 2022 20:16:06 +0000 (22:16 +0200)
src/libsystemd/sd-journal/sd-journal.c

index e8c66a5e2cc8b4a3786ddbbd64f02d7a4e7e4f3f..29e11c0d536fa40b156a5c7775ba2adf7a1a0227 100644 (file)
@@ -493,7 +493,6 @@ static int next_for_match(
 
         int r;
         uint64_t np = 0;
-        Object *n;
 
         assert(j);
         assert(m);
@@ -569,12 +568,12 @@ static int next_for_match(
 
         assert(np > 0);
 
-        r = journal_file_move_to_object(f, OBJECT_ENTRY, np, &n);
-        if (r < 0)
-                return r;
+        if (ret) {
+                r = journal_file_move_to_object(f, OBJECT_ENTRY, np, ret);
+                if (r < 0)
+                        return r;
+        }
 
-        if (ret)
-                *ret = n;
         if (offset)
                 *offset = np;
 
@@ -633,7 +632,6 @@ static int find_location_for_match(
 
         } else if (m->type == MATCH_OR_TERM) {
                 uint64_t np = 0;
-                Object *n;
 
                 /* Find the earliest match */
 
@@ -652,12 +650,12 @@ static int find_location_for_match(
                 if (np == 0)
                         return 0;
 
-                r = journal_file_move_to_object(f, OBJECT_ENTRY, np, &n);
-                if (r < 0)
-                        return r;
+                if (ret) {
+                        r = journal_file_move_to_object(f, OBJECT_ENTRY, np, ret);
+                        if (r < 0)
+                                return r;
+                }
 
-                if (ret)
-                        *ret = n;
                 if (offset)
                         *offset = np;