On Wed, Jan 22, 2025 at 05:37:31PM +0300, Alexander Kuznetsov wrote:
This function return value is invariant since 1022e0ee, so change its type and remove all dependent checks.Found by Linux Verification Center (linuxtesting.org) with Svace. Reported-by: Alexander Rudyuk <[email protected]> Signed-off-by: Alexander Kuznetsov <[email protected]> --- src/conf/domain_conf.c | 9 +++------ src/network/bridge_driver.c | 4 +++- src/util/virnetdevvlan.c | 6 +++--- src/util/virnetdevvlan.h | 2 +- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 8f47ef2574..668870a9ee 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -3973,8 +3973,10 @@ networkAllocatePort(virNetworkObj *obj, else if (netdef->vlan.nTags > 0) vlan = &netdef->vlan; - if (vlan && virNetDevVlanCopy(&port->vlan, vlan) < 0) + if (vlan) { + virNetDevVlanCopy(&port->vlan, vlan); return -1; + }
This is *definitely* not semantically the same as before, beware of such changes!
diff --git a/src/util/virnetdevvlan.c b/src/util/virnetdevvlan.c
index 67daa5d3b4..e8f572efd2 100644
--- a/src/util/virnetdevvlan.c
+++ b/src/util/virnetdevvlan.c
@@ -76,11 +76,11 @@ virNetDevVlanEqual(const virNetDevVlan *a, const
virNetDevVlan *b)
* If src is NULL, dst will have nTags set to 0.
* dst is assumed to be empty on entry.
*/
-int
+void
virNetDevVlanCopy(virNetDevVlan *dst, const virNetDevVlan *src)
{
if (!src || src->nTags == 0)
- return 0;
+ return;
This means you don't even need to check if the source vlan is not NULL before calling this function.
dst->tag = g_new0(unsigned int, src->nTags);
dst->trunk = src->trunk;
@@ -88,5 +88,5 @@ virNetDevVlanCopy(virNetDevVlan *dst, const virNetDevVlan
*src)
dst->nativeMode = src->nativeMode;
dst->nativeTag = src->nativeTag;
memcpy(dst->tag, src->tag, src->nTags * sizeof(*src->tag));
- return 0;
+ return;
Pointless return at the end of a function
}
signature.asc
Description: PGP signature
