From 5c6803f5bd1852fb42230c928250d19f1942c885 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 10 Jul 2017 21:39:23 +0200 Subject: [PATCH] mount: rework find_loop_device() to log about no errors We should either log about all errors in a function, or about none (and then leave the logging about it to the caller who we propagate the error to). Given that the callers of find_loop_device() already log about the returned errors let's hence suppress the log messages in find_loop_device() itself. --- src/mount/mount-tool.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/mount/mount-tool.c b/src/mount/mount-tool.c index 9d56b407000..21c3b1302d1 100644 --- a/src/mount/mount-tool.c +++ b/src/mount/mount-tool.c @@ -759,11 +759,8 @@ static int find_loop_device(const char *backing_file, char **loop_dev) { assert(loop_dev); d = opendir("/sys/devices/virtual/block"); - if (!d) { - if (errno == ENOENT) - return -ENOENT; - return log_error_errno(errno, "Can't open directory /sys/devices/virtual/block: %m"); - } + if (!d) + return -errno; FOREACH_DIRENT(de, d, return -errno) { _cleanup_free_ char *sys = NULL, *fname = NULL; @@ -779,7 +776,7 @@ static int find_loop_device(const char *backing_file, char **loop_dev) { sys = strjoin("/sys/devices/virtual/block/", de->d_name, "/loop/backing_file"); if (!sys) - return log_oom(); + return -ENOMEM; r = read_one_line_file(sys, &fname); if (r < 0) @@ -790,7 +787,7 @@ static int find_loop_device(const char *backing_file, char **loop_dev) { l = strjoin("/dev/", de->d_name); if (!l) - return log_oom(); + return -ENOMEM; break; } -- 2.47.3