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

index a52e5dcb16c8bb5c2a11d9920f3b40f5659eb080..87f4ee4b107883658001e6c8343fae74592f9257 100644 (file)
@@ -15,6 +15,7 @@
 #include "networkd-route.h"
 #include "parse-util.h"
 #include "set.h"
+#include "stdio-util.h"
 #include "string-util.h"
 
 NextHop *nexthop_free(NextHop *nexthop) {
@@ -368,7 +369,7 @@ set_manager:
 }
 
 static void log_nexthop_debug(const NextHop *nexthop, uint32_t id, const char *str, const Link *link) {
-        _cleanup_free_ char *gw = NULL, *new_id = NULL, *group = NULL;
+        _cleanup_free_ char *gw = NULL, *group = NULL;
         struct nexthop_grp *nhg;
 
         assert(nexthop);
@@ -379,8 +380,9 @@ static void log_nexthop_debug(const NextHop *nexthop, uint32_t id, const char *s
         if (!DEBUG_LOGGING)
                 return;
 
+        char new_id[STRLEN("→") + DECIMAL_STR_MAX(uint32_t)] = "";
         if (nexthop->id != id)
-                (void) asprintf(&new_id, "→%"PRIu32, id);
+                xsprintf(new_id, "→%"PRIu32, id);
 
         (void) in_addr_to_string(nexthop->family, &nexthop->gw, &gw);
 
@@ -388,7 +390,7 @@ static void log_nexthop_debug(const NextHop *nexthop, uint32_t id, const char *s
                 (void) strextendf_with_separator(&group, ",", "%"PRIu32":%"PRIu32, nhg->id, nhg->weight+1);
 
         log_link_debug(link, "%s nexthop: id: %"PRIu32"%s, gw: %s, blackhole: %s, group: %s",
-                       str, nexthop->id, strempty(new_id), strna(gw), yes_no(nexthop->blackhole), strna(group));
+                       str, nexthop->id, new_id, strna(gw), yes_no(nexthop->blackhole), strna(group));
 }
 
 static int link_nexthop_remove_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {