]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
shared/killall: replace one trivial asprintf with xsprintf
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 7 Jul 2021 09:37:44 +0000 (11:37 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 9 Jul 2021 09:11:25 +0000 (11:11 +0200)
src/shared/killall.c

index d9fcfc21a9caadf8d89851de25e78d0ce1013d97..869955a58f6c1fa47978c03d411ff8b3ea1e9484 100644 (file)
@@ -17,6 +17,7 @@
 #include "parse-util.h"
 #include "process-util.h"
 #include "set.h"
+#include "stdio-util.h"
 #include "string-util.h"
 #include "terminal-util.h"
 #include "util.h"
@@ -83,14 +84,13 @@ static void log_children_no_yet_killed(Set *pids) {
 
         SET_FOREACH(p, pids) {
                 _cleanup_free_ char *s = NULL;
+                char fallback[DECIMAL_STR_MAX(pid_t)];
 
                 if (get_process_comm(PTR_TO_PID(p), &s) < 0)
-                        (void) asprintf(&s, PID_FMT, PTR_TO_PID(p));
+                        xsprintf(fallback, PID_FMT, PTR_TO_PID(p));
 
-                if (!strextend(&lst_child, ", ", s)) {
-                        log_oom();
-                        return;
-                }
+                if (!strextend(&lst_child, ", ", s ?: fallback))
+                        return (void) log_oom();
         }
 
         if (isempty(lst_child))