]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
virnetdev: Check correct return value for virNetDevFeatureAvailable
authorJohn Ferlan <jferlan@redhat.com>
Tue, 3 Nov 2015 22:01:25 +0000 (17:01 -0500)
committerJohn Ferlan <jferlan@redhat.com>
Wed, 4 Nov 2015 19:28:06 +0000 (14:28 -0500)
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.

Introduced by commit ac3ed20 which changed the helper's return
values without adjusting its callers

Signed-off-by: John Ferlan <jferlan@redhat.com>
src/util/virnetdev.c

index ab006054b6a8e8f2d3f0594ff4c9fd0cb273cdcd..12faf51a475ad82fb174163964740b1623bc8fdb 100644 (file)
@@ -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