[libvirt] [PATCH 16/75] nwfilter: Drop virAsprintf() and virAsprintfQuiet() retval checking

Michal Privoznik mprivozn at redhat.com
Tue Oct 22 13:57:20 UTC 2019


These functions can't fail really. Drop checking of their retval
then.

Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
---
 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..b4ce8a0613 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;
+    virAsprintf(&key, "%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;
+        virAsprintf(&ext_filter, "%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;
-    }
+    virAsprintf(&lbuf, "%u %s %s %s\n", ipl->timeout, ifkey, ipstr, dhcpstr);
     len = strlen(lbuf);
 
     if (safewrite(lfd, lbuf, len) != len) {
-- 
2.21.0




More information about the libvir-list mailing list