提交 b6ac5a82 编写于 作者: D Daniel P. Berrangé

nwfilter: change methods returning virNWFilterIPAddrLearnReq to use bool

Various methods return a virNWFilterIPAddrLearnReq struct, but the
callers are only interested in whether the return value is non-NULL.
It is thus preferrable to just return a bool.
Reviewed-by: NJiri Denemark <jdenemar@redhat.com>
Signed-off-by: NDaniel P. Berrangé <berrange@redhat.com>
上级 d6089632
...@@ -655,7 +655,7 @@ virNWFilterDoInstantiate(const unsigned char *vmuuid, ...@@ -655,7 +655,7 @@ virNWFilterDoInstantiate(const unsigned char *vmuuid,
filter->name, vars, driver); filter->name, vars, driver);
goto err_exit; goto err_exit;
} else if (STRCASEEQ(learning, "any")) { } else if (STRCASEEQ(learning, "any")) {
if (virNWFilterLookupLearnReq(ifindex) == NULL) { if (!virNWFilterHasLearnReq(ifindex)) {
rc = virNWFilterLearnIPAddress(techdriver, rc = virNWFilterLearnIPAddress(techdriver,
ifname, ifname,
ifindex, ifindex,
...@@ -680,7 +680,7 @@ virNWFilterDoInstantiate(const unsigned char *vmuuid, ...@@ -680,7 +680,7 @@ virNWFilterDoInstantiate(const unsigned char *vmuuid,
} else if (virHashSize(missing_vars) > 1) { } else if (virHashSize(missing_vars) > 1) {
goto err_unresolvable_vars; goto err_unresolvable_vars;
} else if (!forceWithPendingReq && } else if (!forceWithPendingReq &&
virNWFilterLookupLearnReq(ifindex) != NULL) { virNWFilterHasLearnReq(ifindex)) {
goto err_exit; goto err_exit;
} }
...@@ -976,7 +976,7 @@ virNWFilterRollbackUpdateFilter(const virDomainNetDef *net) ...@@ -976,7 +976,7 @@ virNWFilterRollbackUpdateFilter(const virDomainNetDef *net)
/* don't tear anything while the address is being learned */ /* don't tear anything while the address is being learned */
if (virNetDevGetIndex(net->ifname, &ifindex) < 0) if (virNetDevGetIndex(net->ifname, &ifindex) < 0)
virResetLastError(); virResetLastError();
else if (virNWFilterLookupLearnReq(ifindex) != NULL) else if (virNWFilterHasLearnReq(ifindex))
return 0; return 0;
return techdriver->tearNewRules(net->ifname); return techdriver->tearNewRules(net->ifname);
...@@ -1002,7 +1002,7 @@ virNWFilterTearOldFilter(virDomainNetDefPtr net) ...@@ -1002,7 +1002,7 @@ virNWFilterTearOldFilter(virDomainNetDefPtr net)
/* don't tear anything while the address is being learned */ /* don't tear anything while the address is being learned */
if (virNetDevGetIndex(net->ifname, &ifindex) < 0) if (virNetDevGetIndex(net->ifname, &ifindex) < 0)
virResetLastError(); virResetLastError();
else if (virNWFilterLookupLearnReq(ifindex) != NULL) else if (virNWFilterHasLearnReq(ifindex))
return 0; return 0;
return techdriver->tearOldRules(net->ifname); return techdriver->tearOldRules(net->ifname);
......
...@@ -279,8 +279,8 @@ virNWFilterTerminateLearnReq(const char *ifname) ...@@ -279,8 +279,8 @@ virNWFilterTerminateLearnReq(const char *ifname)
} }
virNWFilterIPAddrLearnReqPtr bool
virNWFilterLookupLearnReq(int ifindex) virNWFilterHasLearnReq(int ifindex)
{ {
void *res; void *res;
IFINDEX2STR(ifindex_str, ifindex); IFINDEX2STR(ifindex_str, ifindex);
...@@ -291,7 +291,7 @@ virNWFilterLookupLearnReq(int ifindex) ...@@ -291,7 +291,7 @@ virNWFilterLookupLearnReq(int ifindex)
virMutexUnlock(&pendingLearnReqLock); virMutexUnlock(&pendingLearnReqLock);
return res; return res != NULL;
} }
......
...@@ -62,7 +62,7 @@ int virNWFilterLearnIPAddress(virNWFilterTechDriverPtr techdriver, ...@@ -62,7 +62,7 @@ int virNWFilterLearnIPAddress(virNWFilterTechDriverPtr techdriver,
virNWFilterDriverStatePtr driver, virNWFilterDriverStatePtr driver,
enum howDetect howDetect); enum howDetect howDetect);
virNWFilterIPAddrLearnReqPtr virNWFilterLookupLearnReq(int ifindex); bool virNWFilterHasLearnReq(int ifindex);
int virNWFilterTerminateLearnReq(const char *ifname); int virNWFilterTerminateLearnReq(const char *ifname);
int virNWFilterLockIface(const char *ifname) ATTRIBUTE_RETURN_CHECK; int virNWFilterLockIface(const char *ifname) ATTRIBUTE_RETURN_CHECK;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册