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.
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;
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)
l = strjoin("/dev/", de->d_name);
if (!l)
- return log_oom();
+ return -ENOMEM;
break;
}