daandemeyer / rpms / systemd

Forked from rpms/systemd 2 years ago
Clone
40a46b
From cc8cc45e4b7799ac1dad7701de2df3db4fbb790c Mon Sep 17 00:00:00 2001
40a46b
From: Thomas Hindoe Paaboel Andersen <phomes@gmail.com>
40a46b
Date: Fri, 14 Aug 2015 23:40:27 +0200
40a46b
Subject: [PATCH] journal: remove error check that never happens
40a46b
40a46b
remove_directory will always return 0 so this can never happen.
40a46b
Besides that, d->path and d are freed so we would end up with
40a46b
a null pointer dereference anyway.
40a46b
40a46b
(cherry picked from commit b2b46f91dbb71676cb981907c68521e4b1e80af1)
40a46b
40a46b
Related: #1465759
40a46b
---
40a46b
 src/journal/sd-journal.c | 12 +++---------
40a46b
 1 file changed, 3 insertions(+), 9 deletions(-)
40a46b
40a46b
diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c
40a46b
index 72f312b67..3749f9e89 100644
40a46b
--- a/src/journal/sd-journal.c
40a46b
+++ b/src/journal/sd-journal.c
40a46b
@@ -1487,7 +1487,7 @@ static int add_root_directory(sd_journal *j, const char *p) {
40a46b
         return 0;
40a46b
 }
40a46b
 
40a46b
-static int remove_directory(sd_journal *j, Directory *d) {
40a46b
+static void remove_directory(sd_journal *j, Directory *d) {
40a46b
         assert(j);
40a46b
 
40a46b
         if (d->wd > 0) {
40a46b
@@ -1506,8 +1506,6 @@ static int remove_directory(sd_journal *j, Directory *d) {
40a46b
 
40a46b
         free(d->path);
40a46b
         free(d);
40a46b
-
40a46b
-        return 0;
40a46b
 }
40a46b
 
40a46b
 static int add_search_paths(sd_journal *j) {
40a46b
@@ -2145,12 +2143,8 @@ static void process_inotify_event(sd_journal *j, struct inotify_event *e) {
40a46b
 
40a46b
                         /* Event for a subdirectory */
40a46b
 
40a46b
-                        if (e->mask & (IN_DELETE_SELF|IN_MOVE_SELF|IN_UNMOUNT)) {
40a46b
-                                r = remove_directory(j, d);
40a46b
-                                if (r < 0)
40a46b
-                                        log_debug_errno(r, "Failed to remove directory %s: %m", d->path);
40a46b
-                        }
40a46b
-
40a46b
+                        if (e->mask & (IN_DELETE_SELF|IN_MOVE_SELF|IN_UNMOUNT))
40a46b
+                                remove_directory(j, d);
40a46b
 
40a46b
                 } else if (d->is_root && (e->mask & IN_ISDIR) && e->len > 0 && sd_id128_from_string(e->name, &id) >= 0) {
40a46b