summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2021-07-02 16:48:56 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2021-07-19 11:33:44 +0200
commit305757d80819873c8918c6ea229f96fc10b77696 (patch)
treec4919d5b89bc62dc424483f729513b66550d9d9b /src
parenta01ba4b2b8deeb31c65f8ed525ebab51972919bf (diff)
downloadsystemd-305757d80819873c8918c6ea229f96fc10b77696.tar.gz
core: modernize asprintf error handling
The man page says asprintf() pointer is "undefined" on error, but the only meaningful interpretation is that it's either NULL or points to something that should be freed with free().
Diffstat (limited to 'src')
-rw-r--r--src/core/manager.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/src/core/manager.c b/src/core/manager.c
index 72f1e109d7..594be370c6 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -230,8 +230,7 @@ static void manager_print_jobs_in_progress(Manager *m) {
m->jobs_in_progress_iteration++;
if (m->n_running_jobs > 1)
- if (asprintf(&job_of_n, "(%u of %u) ", counter, m->n_running_jobs) < 0)
- job_of_n = NULL;
+ (void) asprintf(&job_of_n, "(%u of %u) ", counter, m->n_running_jobs);
bool have_timeout = job_get_timeout(j, &x) > 0;
@@ -620,9 +619,7 @@ static char** sanitize_environment(char **l) {
NULL);
/* Let's order the environment alphabetically, just to make it pretty */
- strv_sort(l);
-
- return l;
+ return strv_sort(l);
}
int manager_default_environment(Manager *m) {
@@ -3142,10 +3139,8 @@ void manager_send_unit_plymouth(Manager *m, Unit *u) {
return;
}
- if (asprintf(&message, "U\002%c%s%n", (int) (strlen(u->id) + 1), u->id, &n) < 0) {
- log_oom();
- return;
- }
+ if (asprintf(&message, "U\002%c%s%n", (int) (strlen(u->id) + 1), u->id, &n) < 0)
+ return (void) log_oom();
errno = 0;
if (write(fd, message, n + 1) != n + 1)