]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-journal: use more appropriate API to validate 128bit ids
authorLennart Poettering <lennart@poettering.net>
Thu, 8 Feb 2018 19:10:51 +0000 (20:10 +0100)
committerLennart Poettering <lennart@poettering.net>
Mon, 12 Feb 2018 10:07:55 +0000 (11:07 +0100)
We have id128_is_valid(), let's use it.

src/journal/sd-journal.c

index 4df0abe32922baccee1ea360b5b8a6d947b12dd3..78d714a7cd7e8bb5d456895c97bd712cc3e6c6c4 100644 (file)
@@ -40,6 +40,7 @@
 #include "fs-util.h"
 #include "hashmap.h"
 #include "hostname-util.h"
+#include "id128-util.h"
 #include "io-util.h"
 #include "journal-def.h"
 #include "journal-file.h"
@@ -1140,7 +1141,6 @@ _public_ int sd_journal_test_cursor(sd_journal *j, const char *cursor) {
         return 1;
 }
 
-
 _public_ int sd_journal_seek_monotonic_usec(sd_journal *j, sd_id128_t boot_id, uint64_t usec) {
         assert_return(j, -EINVAL);
         assert_return(!journal_pid_changed(j), -ECHILD);
@@ -2369,8 +2369,6 @@ static void process_inotify_event(sd_journal *j, struct inotify_event *e) {
         /* Is this a subdirectory we watch? */
         d = hashmap_get(j->directories_by_wd, INT_TO_PTR(e->wd));
         if (d) {
-                sd_id128_t id;
-
                 if (!(e->mask & IN_ISDIR) && e->len > 0 &&
                     (endswith(e->name, ".journal") ||
                      endswith(e->name, ".journal~"))) {
@@ -2389,7 +2387,7 @@ static void process_inotify_event(sd_journal *j, struct inotify_event *e) {
                         if (e->mask & (IN_DELETE_SELF|IN_MOVE_SELF|IN_UNMOUNT))
                                 remove_directory(j, d);
 
-                } else if (d->is_root && (e->mask & IN_ISDIR) && e->len > 0 && sd_id128_from_string(e->name, &id) >= 0) {
+                } else if (d->is_root && (e->mask & IN_ISDIR) && e->len > 0 && id128_is_valid(e->name)) {
 
                         /* Event for root directory */
 
@@ -2403,7 +2401,7 @@ static void process_inotify_event(sd_journal *j, struct inotify_event *e) {
         if (e->mask & IN_IGNORED)
                 return;
 
-        log_debug("Unknown inotify event.");
+        log_debug("Unexpected inotify event.");
 }
 
 static int determine_change(sd_journal *j) {