From: Dmitry V. Levin Date: Fri, 7 Jul 2023 08:00:00 +0000 (+0000) Subject: kbd-util: fix use of ERRNO_IS_RESOURCE() X-Git-Tag: v254-rc3~37^2~4 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ed3745b51cd823d4a651e250050b2b674f055585;p=thirdparty%2Fsystemd.git kbd-util: fix use of ERRNO_IS_RESOURCE() Given that ERRNO_IS_RESOURCE() also matches positive values, make sure this macro is not called with arguments that do not have errno semantics. In this case the argument passed to ERRNO_IS_RESOURCE() is the value returned by recurse_dir_at() which can legitimately return positive values without errno semantics, so fix this by moving the ERRNO_IS_RESOURCE() invocation to the branch where the return value is known to be negative. --- diff --git a/src/shared/kbd-util.c b/src/shared/kbd-util.c index 31008625483..e6fe973471b 100644 --- a/src/shared/kbd-util.c +++ b/src/shared/kbd-util.c @@ -145,11 +145,11 @@ int keymap_exists(const char *name) { &(struct recurse_dir_userdata) { .keymap_name = name, }); - if (r == -ENOENT) - continue; - if (ERRNO_IS_RESOURCE(r)) - return r; 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; }