From: Zbigniew Jędrzejewski-Szmek Date: Thu, 10 Aug 2023 08:02:34 +0000 (+0200) Subject: shared/kbd-util: simplify error handling in keymap_exists() X-Git-Tag: v255-rc1~706^2~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7d01eb35dc155d2cb183d08fa72705488e69967c;p=thirdparty%2Fsystemd.git shared/kbd-util: simplify error handling in keymap_exists() Once we know the return value, we can just return it, no need to exit the loop. --- diff --git a/src/shared/kbd-util.c b/src/shared/kbd-util.c index e4e7926bf96..2f2d161ca68 100644 --- a/src/shared/kbd-util.c +++ b/src/shared/kbd-util.c @@ -127,7 +127,7 @@ bool keymap_is_valid(const char *name) { } int keymap_exists(const char *name) { - int r = 0; + int r; if (!keymap_is_valid(name)) return -EINVAL; @@ -143,17 +143,13 @@ int keymap_exists(const char *name) { &(struct recurse_dir_userdata) { .keymap_name = name, }); - if (r < 0) { - if (r == -ENOENT) - continue; - if (ERRNO_IS_RESOURCE(r)) - return r; - log_debug_errno(r, "Failed to read keymap list from %s, ignoring: %m", dir); - continue; - } if (r > 0) - break; + return true; + if (ERRNO_IS_NEG_RESOURCE(r)) + return r; + if (r < 0 && r != -ENOENT) + log_debug_errno(r, "Failed to read keymap list from %s, ignoring: %m", dir); } - return r > 0; + return false; }