1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-03-12 08:58:20 +03:00

tmpfiles: ERRNO_IS_NOINFO -> _IS_NEG_, correct negative errno checks

(cherry picked from commit 755877f20a2e18d1a2c4149662c2caec80230879)
(cherry picked from commit 7884db1b93754901750f21cf1c04e38be0e94f11)
This commit is contained in:
Mike Yuan 2024-09-19 13:38:47 +02:00 committed by Luca Boccassi
parent 75e6be9d42
commit 56f4272ac7

View File

@ -241,12 +241,12 @@ static void context_done(Context *c) {
}
/* Different kinds of errors that mean that information is not available in the environment. */
static bool ERRNO_IS_NOINFO(int r) {
return IN_SET(abs(r),
EUNATCH, /* os-release or machine-id missing */
ENOMEDIUM, /* machine-id or another file empty */
ENOPKG, /* machine-id is uninitialized */
ENXIO); /* env var is unset */
static bool ERRNO_IS_NEG_NOINFO(intmax_t r) {
return IN_SET(r,
-EUNATCH, /* os-release or machine-id missing */
-ENOMEDIUM, /* machine-id or another file empty */
-ENOPKG, /* machine-id is uninitialized */
-ENXIO); /* env var is unset */
}
static int specifier_directory(char specifier, const void *data, const char *root, const void *userdata, char **ret) {
@ -339,15 +339,15 @@ static int user_config_paths(char*** ret) {
return r;
r = xdg_user_config_dir(&persistent_config, "/user-tmpfiles.d");
if (r < 0 && !ERRNO_IS_NOINFO(r))
if (r < 0 && !ERRNO_IS_NEG_NOINFO(r))
return r;
r = xdg_user_runtime_dir(&runtime_config, "/user-tmpfiles.d");
if (r < 0 && !ERRNO_IS_NOINFO(r))
if (r < 0 && !ERRNO_IS_NEG_NOINFO(r))
return r;
r = xdg_user_data_dir(&data_home, "/user-tmpfiles.d");
if (r < 0 && !ERRNO_IS_NOINFO(r))
if (r < 0 && !ERRNO_IS_NEG_NOINFO(r))
return r;
r = strv_extend_strv_concat(&res, config_dirs, "/user-tmpfiles.d");
@ -3526,7 +3526,7 @@ static int parse_line(
i.try_replace = try_replace;
r = specifier_printf(path, PATH_MAX-1, specifier_table, arg_root, NULL, &i.path);
if (ERRNO_IS_NOINFO(r))
if (ERRNO_IS_NEG_NOINFO(r))
return log_unresolvable_specifier(fname, line);
if (r < 0) {
if (IN_SET(r, -EINVAL, -EBADSLT))
@ -3680,7 +3680,7 @@ static int parse_line(
if (!unbase64) {
/* Do specifier expansion except if base64 mode is enabled */
r = specifier_expansion_from_arg(specifier_table, &i);
if (ERRNO_IS_NOINFO(r))
if (ERRNO_IS_NEG_NOINFO(r))
return log_unresolvable_specifier(fname, line);
if (r < 0) {
if (IN_SET(r, -EINVAL, -EBADSLT))
@ -4556,7 +4556,7 @@ static int run(int argc, char *argv[]) {
}
}
if (ERRNO_IS_RESOURCE(r))
if (ERRNO_IS_NEG_RESOURCE(r))
return r;
if (invalid_config)
return EX_DATAERR;