chiark / gitweb /
journald: fix some xsprrintf() buffer size fallout
[elogind.git] / src / journal / test-journal-flush.c
index 0ca24e0cb5a971d0aa78080cc77f7ff0273669f0..914ca0b4d1da1313078d5090c5b7bf0e986e75b8 100644 (file)
@@ -22,6 +22,7 @@
 #include <fcntl.h>
 
 #include "sd-journal.h"
+#include "macro.h"
 #include "journal-file.h"
 #include "journal-internal.h"
 
@@ -39,8 +40,6 @@ int main(int argc, char *argv[]) {
         r = journal_file_open(fn, O_CREAT|O_RDWR, 0644, false, false, NULL, NULL, NULL, &new_journal);
         assert_se(r >= 0);
 
-        unlink(fn);
-
         r = sd_journal_open(&j, 0);
         assert_se(r >= 0);
 
@@ -51,13 +50,13 @@ int main(int argc, char *argv[]) {
                 JournalFile *f;
 
                 f = j->current_file;
-                assert(f && f->current_offset > 0);
+                assert_se(f && f->current_offset > 0);
 
                 r = journal_file_move_to_object(f, OBJECT_ENTRY, f->current_offset, &o);
-                assert(r >= 0);
+                assert_se(r >= 0);
 
                 r = journal_file_copy_entry(f, new_journal, o, f->current_offset, NULL, NULL, NULL);
-                assert(r >= 0);
+                assert_se(r >= 0);
 
                 n++;
                 if (n > 10000)
@@ -68,6 +67,7 @@ int main(int argc, char *argv[]) {
 
         journal_file_close(new_journal);
 
+        unlink(fn);
         assert_se(rmdir(dn) == 0);
 
         return 0;