提交 4ee1b16a 编写于 作者: J John Ferlan

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 ac3ed208 which changed the helper's return
values without adjusting its callers
Signed-off-by: NJohn Ferlan <jferlan@redhat.com>
上级 703ec1b7
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册