Skip to content

Commit 338ef2b

Browse files
ldv-altbluca
authored andcommitted
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. (cherry picked from commit ed3745b) (cherry picked from commit 24256d0)
1 parent 6e798f7 commit 338ef2b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/shared/kbd-util.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,11 @@ int keymap_exists(const char *name) {
147147
&(struct recurse_dir_userdata) {
148148
.keymap_name = name,
149149
});
150-
if (r == -ENOENT)
151-
continue;
152-
if (ERRNO_IS_RESOURCE(r))
153-
return r;
154150
if (r < 0) {
151+
if (r == -ENOENT)
152+
continue;
153+
if (ERRNO_IS_RESOURCE(r))
154+
return r;
155155
log_debug_errno(r, "Failed to read keymap list from %s, ignoring: %m", dir);
156156
continue;
157157
}

0 commit comments

Comments
 (0)