chiark / gitweb /
journal: fix seeking by realtime/seqnum
[elogind.git] / src / journal / journal-file.c
index c468b226972d1ebffe02177584b384aaea642a6c..9665a0535bc038d62ca16a7b756851e2239721d6 100644 (file)
@@ -1300,7 +1300,7 @@ static int generic_array_bisect_plus_one(JournalFile *f,
 
         r = generic_array_bisect(f, first, n-1, needle, test_object, direction, ret, offset, idx);
 
-        if (r > 0)
+        if (r > 0 && idx)
                 (*idx) ++;
 
         return r;
@@ -1611,8 +1611,10 @@ int journal_file_move_to_entry_by_seqnum_for_data(
         Object *d;
         int r;
 
+        assert(f);
+
         r = journal_file_move_to_object(f, OBJECT_DATA, data_offset, &d);
-        if (r <= 0)
+        if (r < 0)
                 return r;
 
         return generic_array_bisect_plus_one(f,
@@ -1635,8 +1637,10 @@ int journal_file_move_to_entry_by_realtime_for_data(
         Object *d;
         int r;
 
+        assert(f);
+
         r = journal_file_move_to_object(f, OBJECT_DATA, data_offset, &d);
-        if (r <= 0)
+        if (r < 0)
                 return r;
 
         return generic_array_bisect_plus_one(f,