From: Yu Watanabe Date: Sat, 8 Apr 2023 16:31:29 +0000 (+0900) Subject: os-util: do not use 'r' for storing loop status X-Git-Tag: v254-rc1~760^2~6 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c9d64f8a2cc743d8309bb1b2246f49f834437a06;p=thirdparty%2Fsystemd.git os-util: do not use 'r' for storing loop status The variable 'r' is usually used for storing return value of functional call. Let's introduce another boolean to store the current loop status. No functional change, just refactoring. --- diff --git a/src/basic/os-util.c b/src/basic/os-util.c index 35c7555461d..0ca307064e5 100644 --- a/src/basic/os-util.c +++ b/src/basic/os-util.c @@ -149,6 +149,7 @@ int open_extension_release( _cleanup_close_ int fd = -EBADF; _cleanup_free_ char *q = NULL; + bool found = false; int r; assert(!extension || (image_class >= 0 && image_class < _IMAGE_CLASS_MAX)); @@ -183,7 +184,6 @@ int open_extension_release( if (r < 0) return log_debug_errno(r, "Cannot open %s%s, ignoring: %m", root, image_class_release_info[image_class].release_file_directory); - r = -ENOENT; FOREACH_DIRENT(de, extension_release_dir, return -errno) { int k; @@ -228,12 +228,10 @@ int open_extension_release( /* We already found what we were looking for, but there's another candidate? We treat this as * an error, as we want to enforce that there are no ambiguities in case we are in the * fallback path. */ - if (r == 0) { - r = -ENOTUNIQ; - break; - } + if (found) + return -ENOTUNIQ; - r = 0; /* Found it! */ + found = true; if (ret_fd) fd = TAKE_FD(extension_release_fd); @@ -244,8 +242,8 @@ int open_extension_release( return -ENOMEM; } } - if (r < 0) - return r; + if (!found) + return -ENOENT; if (ret_fd) *ret_fd = TAKE_FD(fd);