diff options
author | Luca Boccassi <bluca@debian.org> | 2024-07-02 10:05:49 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-02 10:05:49 +0200 |
commit | 1b3dc176241c1f1bdb289daa0f44de4fab9340f0 (patch) | |
tree | ae08aeacb5f2780341fc3601a8cdd56f9a71e9a8 | |
parent | Merge pull request #33523 from neighbourhoodie/fix/dns-opt-extended-rcode (diff) | |
parent | shared/condition: add missing space after 'if' (diff) | |
download | systemd-1b3dc176241c1f1bdb289daa0f44de4fab9340f0.tar.xz systemd-1b3dc176241c1f1bdb289daa0f44de4fab9340f0.zip |
Merge pull request #33560 from YHNdnzj/trivial-cleanup-2
2 trivial follow-ups for recent PRs
-rw-r--r-- | src/shared/condition.c | 4 | ||||
-rw-r--r-- | src/shared/mount-util.h | 17 |
2 files changed, 12 insertions, 9 deletions
diff --git a/src/shared/condition.c b/src/shared/condition.c index 1f72ba8b0f..2e231dfdff 100644 --- a/src/shared/condition.c +++ b/src/shared/condition.c @@ -1008,8 +1008,8 @@ static int condition_test_psi(Condition *c, char **env) { const char *p, *value, *pressure_type; loadavg_t *current, limit; ResourcePressure pressure; - int r; PressureType preferred_pressure_type = PRESSURE_TYPE_FULL; + int r; assert(c); assert(c->parameter); @@ -1031,7 +1031,7 @@ static int condition_test_psi(Condition *c, char **env) { /* If only one parameter is passed, then we look at the global system pressure rather than a specific cgroup. */ if (r == 1) { /* cpu.pressure 'full' is reported but undefined at system level */ - if(c->type == CONDITION_CPU_PRESSURE) + if (c->type == CONDITION_CPU_PRESSURE) preferred_pressure_type = PRESSURE_TYPE_SOME; pressure_path = path_join("/proc/pressure", pressure_type); diff --git a/src/shared/mount-util.h b/src/shared/mount-util.h index 20c63e137f..c260eef02a 100644 --- a/src/shared/mount-util.h +++ b/src/shared/mount-util.h @@ -83,19 +83,22 @@ int mount_flags_to_string(unsigned long flags, char **ret); /* Useful for usage with _cleanup_(), unmounts, removes a directory and frees the pointer */ static inline char* umount_and_rmdir_and_free(char *p) { + if (!p) + return NULL; + PROTECT_ERRNO; - if (p) { - (void) umount_recursive(p, 0); - (void) rmdir(p); - } + (void) umount_recursive(p, 0); + (void) rmdir(p); return mfree(p); } DEFINE_TRIVIAL_CLEANUP_FUNC(char*, umount_and_rmdir_and_free); -static inline char *umount_and_free(char *p) { +static inline char* umount_and_free(char *p) { + if (!p) + return NULL; + PROTECT_ERRNO; - if (p) - (void) umount_recursive(p, 0); + (void) umount_recursive(p, 0); return mfree(p); } DEFINE_TRIVIAL_CLEANUP_FUNC(char*, umount_and_free); |