Re: [PATCH] util: netdevvlan: Change return type of virNetDevVlanCopy to void

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <a.rudyuk@xxxxxxxxxxx>
Signed-off-by: Alexander Kuznetsov <kuznetsovam@xxxxxxxxxxxx>
---
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

}

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux