From c09b0fe7a7c0893880a35a55e26e72ffed96a895 Mon Sep 17 00:00:00 2001 From: Michal Privoznik Date: Tue, 22 Oct 2019 15:26:14 +0200 Subject: [PATCH] nwfilter: Use g_strdup_printf() instead of virAsprintf() Signed-off-by: Michal Privoznik Reviewed-by: Daniel Henrique Barboza --- src/nwfilter/nwfilter_dhcpsnoop.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/nwfilter/nwfilter_dhcpsnoop.c b/src/nwfilter/nwfilter_dhcpsnoop.c index 665e7bff9c..4e77ca0d2d 100644 --- a/src/nwfilter/nwfilter_dhcpsnoop.c +++ b/src/nwfilter/nwfilter_dhcpsnoop.c @@ -315,8 +315,7 @@ virNWFilterSnoopActivate(virNWFilterSnoopReqPtr req) { char *key; - if (virAsprintf(&key, "%p-%d", req, req->ifindex) < 0) - return NULL; + key = g_strdup_printf("%p-%d", req, req->ifindex); virNWFilterSnoopActiveLock(); @@ -1081,9 +1080,7 @@ virNWFilterSnoopDHCPOpen(const char *ifname, virMacAddr *mac, * extend the filter with the macaddr of the VM; filter the * more unlikely parameters first, then go for the MAC */ - if (virAsprintf(&ext_filter, - "%s and ether src %s", filter, macaddr) < 0) - return NULL; + ext_filter = g_strdup_printf("%s and ether src %s", filter, macaddr); } else { /* * Some DHCP servers respond via MAC broadcast; we rely on later @@ -1766,11 +1763,7 @@ virNWFilterSnoopLeaseFileWrite(int lfd, const char *ifkey, } /* time intf ip dhcpserver */ - if (virAsprintf(&lbuf, "%u %s %s %s\n", ipl->timeout, - ifkey, ipstr, dhcpstr) < 0) { - ret = -1; - goto cleanup; - } + lbuf = g_strdup_printf("%u %s %s %s\n", ipl->timeout, ifkey, ipstr, dhcpstr); len = strlen(lbuf); if (safewrite(lfd, lbuf, len) != len) {