summaryrefslogtreecommitdiffstats
path: root/src/oom/oomd-util.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 03:50:42 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 03:50:42 +0000
commit78e9bb837c258ac0ec7712b3d612cc2f407e731e (patch)
treef515d16b6efd858a9aeb5b0ef5d6f90bf288283d /src/oom/oomd-util.c
parentAdding debian version 255.5-1. (diff)
downloadsystemd-78e9bb837c258ac0ec7712b3d612cc2f407e731e.tar.xz
systemd-78e9bb837c258ac0ec7712b3d612cc2f407e731e.zip
Merging upstream version 256.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/oom/oomd-util.c')
-rw-r--r--src/oom/oomd-util.c30
1 files changed, 14 insertions, 16 deletions
diff --git a/src/oom/oomd-util.c b/src/oom/oomd-util.c
index f9f0af2..69d103e 100644
--- a/src/oom/oomd-util.c
+++ b/src/oom/oomd-util.c
@@ -276,7 +276,7 @@ int oomd_cgroup_kill(const char *path, bool recurse, bool dry_run) {
if (r < 0)
log_debug_errno(r, "Failed to set user.oomd_kill on kill: %m");
- return set_size(pids_killed) != 0;
+ return !set_isempty(pids_killed);
}
typedef void (*dump_candidate_func)(const OomdCGroupContext *ctx, FILE *f, const char *prefix);
@@ -321,17 +321,16 @@ int oomd_kill_by_pgscan_rate(Hashmap *h, const char *prefix, bool dry_run, char
if (r == -ENOMEM)
return r; /* Treat oom as a hard error */
if (r < 0) {
- if (ret == 0)
- ret = r;
+ RET_GATHER(ret, r);
continue; /* Try to find something else to kill */
}
dump_until = MAX(dump_until, i + 1);
- char *selected = strdup(sorted[i]->path);
- if (!selected)
- return -ENOMEM;
- *ret_selected = selected;
+
ret = r;
+ r = strdup_to(ret_selected, sorted[i]->path);
+ if (r < 0)
+ return r;
break;
}
@@ -365,17 +364,16 @@ int oomd_kill_by_swap_usage(Hashmap *h, uint64_t threshold_usage, bool dry_run,
if (r == -ENOMEM)
return r; /* Treat oom as a hard error */
if (r < 0) {
- if (ret == 0)
- ret = r;
+ RET_GATHER(ret, r);
continue; /* Try to find something else to kill */
}
dump_until = MAX(dump_until, i + 1);
- char *selected = strdup(sorted[i]->path);
- if (!selected)
- return -ENOMEM;
- *ret_selected = selected;
+
ret = r;
+ r = strdup_to(ret_selected, sorted[i]->path);
+ if (r < 0)
+ return r;
break;
}
@@ -442,9 +440,9 @@ int oomd_cgroup_context_acquire(const char *path, OomdCGroupContext **ret) {
return log_debug_errno(r, "Error converting pgscan value to uint64_t: %m");
}
- ctx->path = strdup(empty_to_root(path));
- if (!ctx->path)
- return -ENOMEM;
+ r = strdup_to(&ctx->path, empty_to_root(path));
+ if (r < 0)
+ return r;
*ret = TAKE_PTR(ctx);
return 0;