From ed3745b51cd823d4a651e250050b2b674f055585 Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Fri, 7 Jul 2023 08:00:00 +0000 Subject: [PATCH] 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. --- src/shared/kbd-util.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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; } -- 2.47.3