]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
fuzz-journal-remote: use ASSERT_OK() and friends 35774/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 28 Dec 2024 05:17:47 +0000 (14:17 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 28 Dec 2024 05:17:47 +0000 (14:17 +0900)
src/journal-remote/fuzz-journal-remote.c

index 3e874f19b71be29f7b32026a31d6ab8a6b54b092..3c44945cd45dc4829a8e92f6bb3931aa1472b6b3 100644 (file)
@@ -16,6 +16,7 @@
 #include "path-util.h"
 #include "rm-rf.h"
 #include "strv.h"
+#include "tests.h"
 #include "tmpfile-util.h"
 
 int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
@@ -50,14 +51,11 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
                 return r;
         }
 
-        r = journal_remote_add_source(&s, fdin, (char*) "fuzz-data", false);
-        if (r < 0)
-                return r;
+        ASSERT_OK_POSITIVE(journal_remote_add_source(&s, fdin, (char*) "fuzz-data", false));
         TAKE_FD(fdin_close);
-        assert(r > 0);
 
         while (s.active)
-                assert_se(journal_remote_handle_raw_source(NULL, fdin, 0, &s) >= 0);
+                ASSERT_OK(journal_remote_handle_raw_source(NULL, fdin, 0, &s));
 
         assert_se(close(fdin) < 0 && errno == EBADF); /* Check that the fd is closed already */
 
@@ -80,11 +78,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
         for (OutputMode mode = 0; mode < _OUTPUT_MODE_MAX; mode++) {
                 if (!dev_null)
                         log_info("/* %s */", output_mode_to_string(mode));
-                r = show_journal(dev_null ?: stdout, j, mode, 0, 0, -1, 0, NULL);
-                assert_se(r >= 0);
-
-                r = sd_journal_seek_head(j);
-                assert_se(r >= 0);
+                ASSERT_OK(show_journal(dev_null ?: stdout, j, mode, 0, 0, -1, 0, NULL));
+                ASSERT_OK(sd_journal_seek_head(j));
         }
 
         return 0;