From: Lennart Poettering Date: Mon, 10 Jul 2017 19:39:23 +0000 (+0200) Subject: mount: rework find_loop_device() to log about no errors X-Git-Tag: v234~13^2~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5c6803f5bd1852fb42230c928250d19f1942c885;p=thirdparty%2Fsystemd.git 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. --- 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; }