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