[libvirt] [PATCH 1/3] virnetdev: Check correct return value for virNetDevFeatureAvailable

John Ferlan jferlan at redhat.com
Wed Nov 4 00:18:09 UTC 2015


Rather than "if (virNetDevFeatureAvailable(ifname, &cmd))" change the
success criteria to "if (virNetDevFeatureAvailable(ifname, &cmd) == 1)".

The called helper returns -1 on failure, 0 on not found, and 1 on found.
Thus a failure was setting bits.

Signed-off-by: John Ferlan <jferlan at redhat.com>
---
 src/util/virnetdev.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c
index ab00605..12faf51 100644
--- a/src/util/virnetdev.c
+++ b/src/util/virnetdev.c
@@ -3250,7 +3250,7 @@ virNetDevGetFeatures(const char *ifname,
 
     for (i = 0; i < ARRAY_CARDINALITY(cmds); i++) {
         cmd.cmd = cmds[i].cmd;
-        if (virNetDevFeatureAvailable(ifname, &cmd))
+        if (virNetDevFeatureAvailable(ifname, &cmd) == 1)
             ignore_value(virBitmapSetBit(*out, cmds[i].feat));
     }
 
@@ -3274,7 +3274,7 @@ virNetDevGetFeatures(const char *ifname,
     };
 
     cmd.cmd = ETHTOOL_GFLAGS;
-    if (virNetDevFeatureAvailable(ifname, &cmd)) {
+    if (virNetDevFeatureAvailable(ifname, &cmd) == 1) {
         for (j = 0; j < ARRAY_CARDINALITY(flags); j++) {
             if (cmd.data & flags[j].cmd)
                 ignore_value(virBitmapSetBit(*out, flags[j].feat));
@@ -3288,7 +3288,7 @@ virNetDevGetFeatures(const char *ifname,
         return -1;
     g_cmd->cmd = ETHTOOL_GFEATURES;
     g_cmd->size = GFEATURES_SIZE;
-    if (virNetDevGFeatureAvailable(ifname, g_cmd))
+    if (virNetDevGFeatureAvailable(ifname, g_cmd) == 1)
         ignore_value(virBitmapSetBit(*out, VIR_NET_DEV_FEAT_TXUDPTNL));
     VIR_FREE(g_cmd);
 # endif
-- 
2.1.0




More information about the libvir-list mailing list