diff options
author | Lennart Poettering <lennart@poettering.net> | 2022-10-10 11:06:56 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2022-10-10 16:00:15 +0200 |
commit | 00675c363ffdb0144873ae24ce555556aedcab0d (patch) | |
tree | cb704aa245834efce4ec64d17870304b276a7dfc /src/oom | |
parent | dcf1bf3b6dd934d3af629a1f9f24e083fce85255 (diff) | |
download | systemd-00675c363ffdb0144873ae24ce555556aedcab0d.tar.gz |
tree-wide: add ERRNO_IS_XATTR_ABSENT() helper
We check the same list of error codes on various xattr operations, and
we should on some more. Add a common helper for this purpose.
Diffstat (limited to 'src/oom')
-rw-r--r-- | src/oom/oomd-util.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/oom/oomd-util.c b/src/oom/oomd-util.c index d31d5ca623..1fc81d1843 100644 --- a/src/oom/oomd-util.c +++ b/src/oom/oomd-util.c @@ -3,6 +3,7 @@ #include <sys/xattr.h> #include <unistd.h> +#include "errno-util.h" #include "fd-util.h" #include "fileio.h" #include "format-util.h" @@ -39,7 +40,7 @@ static int increment_oomd_xattr(const char *path, const char *xattr, uint64_t nu assert(xattr); r = cg_get_xattr_malloc(SYSTEMD_CGROUP_CONTROLLER, path, xattr, &value); - if (r < 0 && r != -ENODATA) + if (r < 0 && !ERRNO_IS_XATTR_ABSENT(r)) return r; if (!isempty(value)) { @@ -169,14 +170,14 @@ int oomd_fetch_cgroup_oom_preference(OomdCGroupContext *ctx, const char *prefix) r = cg_get_xattr_bool(SYSTEMD_CGROUP_CONTROLLER, ctx->path, "user.oomd_avoid"); if (r == -ENOMEM) return log_oom_debug(); - if (r < 0 && r != -ENODATA) + if (r < 0 && !ERRNO_IS_XATTR_ABSENT(r)) log_debug_errno(r, "Failed to get xattr user.oomd_avoid, ignoring: %m"); ctx->preference = r > 0 ? MANAGED_OOM_PREFERENCE_AVOID : ctx->preference; r = cg_get_xattr_bool(SYSTEMD_CGROUP_CONTROLLER, ctx->path, "user.oomd_omit"); if (r == -ENOMEM) return log_oom_debug(); - if (r < 0 && r != -ENODATA) + if (r < 0 && !ERRNO_IS_XATTR_ABSENT(r)) log_debug_errno(r, "Failed to get xattr user.oomd_omit, ignoring: %m"); ctx->preference = r > 0 ? MANAGED_OOM_PREFERENCE_OMIT : ctx->preference; } else |