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 <jferlan@redhat.com>
This commit is contained in:
John Ferlan 2015-11-03 17:01:25 -05:00
parent 703ec1b73d
commit 4ee1b16a54

View File

@ -3250,7 +3250,7 @@ virNetDevGetFeatures(const char *ifname,
for (i = 0; i < ARRAY_CARDINALITY(cmds); i++) { for (i = 0; i < ARRAY_CARDINALITY(cmds); i++) {
cmd.cmd = cmds[i].cmd; cmd.cmd = cmds[i].cmd;
if (virNetDevFeatureAvailable(ifname, &cmd)) if (virNetDevFeatureAvailable(ifname, &cmd) == 1)
ignore_value(virBitmapSetBit(*out, cmds[i].feat)); ignore_value(virBitmapSetBit(*out, cmds[i].feat));
} }
@ -3274,7 +3274,7 @@ virNetDevGetFeatures(const char *ifname,
}; };
cmd.cmd = ETHTOOL_GFLAGS; cmd.cmd = ETHTOOL_GFLAGS;
if (virNetDevFeatureAvailable(ifname, &cmd)) { if (virNetDevFeatureAvailable(ifname, &cmd) == 1) {
for (j = 0; j < ARRAY_CARDINALITY(flags); j++) { for (j = 0; j < ARRAY_CARDINALITY(flags); j++) {
if (cmd.data & flags[j].cmd) if (cmd.data & flags[j].cmd)
ignore_value(virBitmapSetBit(*out, flags[j].feat)); ignore_value(virBitmapSetBit(*out, flags[j].feat));
@ -3288,7 +3288,7 @@ virNetDevGetFeatures(const char *ifname,
return -1; return -1;
g_cmd->cmd = ETHTOOL_GFEATURES; g_cmd->cmd = ETHTOOL_GFEATURES;
g_cmd->size = GFEATURES_SIZE; 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)); ignore_value(virBitmapSetBit(*out, VIR_NET_DEV_FEAT_TXUDPTNL));
VIR_FREE(g_cmd); VIR_FREE(g_cmd);
# endif # endif