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.
This commit is contained in:
Dmitry V. Levin
2023-07-16 10:53:30 +00:00
parent d980371669
commit ed3745b51c
+4 -4
View File
@@ -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;
}