Skip to content

Commit

Permalink
kbd-util: fix use of ERRNO_IS_RESOURCE()
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ldv-alt committed Jul 16, 2023
1 parent d980371 commit ed3745b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/shared/kbd-util.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit ed3745b

Please sign in to comment.