ryantimwilson / rpms / systemd

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