From: John Ferlan Date: Tue, 3 Nov 2015 22:01:25 +0000 (-0500) Subject: virnetdev: Check correct return value for virNetDevFeatureAvailable X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=4ee1b16a54f61be5cadd8de9ede062cb535ebf28;p=people%2Fliuw%2Flibxenctrl-split%2Flibvirt.git virnetdev: Check correct return value for virNetDevFeatureAvailable 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 --- diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c index ab006054b..12faf51a4 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