Skip to content

Commit 24256d0

Browse files
ldv-altkeszybz
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)
1 parent 5d62126 commit 24256d0

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
@@ -145,11 +145,11 @@ int keymap_exists(const char *name) {
145145
&(struct recurse_dir_userdata) {
146146
.keymap_name = name,
147147
});
148-
if (r == -ENOENT)
149-
continue;
150-
if (ERRNO_IS_RESOURCE(r))
151-
return r;
152148
if (r < 0) {
149+
if (r == -ENOENT)
150+
continue;
151+
if (ERRNO_IS_RESOURCE(r))
152+
return r;
153153
log_debug_errno(r, "Failed to read keymap list from %s, ignoring: %m", dir);
154154
continue;
155155
}

0 commit comments

Comments
 (0)