Re: [libvirt] [PATCH] remove useless code

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

 



Jim Meyering <jim@xxxxxxxxxxxx> wrote:
>>From a7cae36a3d966e80d82859d63c60a303b63d6720 Mon Sep 17 00:00:00 2001
> From: Jim Meyering <meyering@xxxxxxxxxx>
> Date: Wed, 4 Feb 2009 17:44:24 +0100
> Subject: [PATCH] remove useless code
>
> * src/bridge.c (brAddTap): Remove redundant errno=ENOMEM assignment
> after failed strdup.
> * src/cgroup.c (virCgroupFree): Remove redundant *group=NULL assignment
> after VIR_FREE(*group).

I found a few more.
Each of the last two are ok because the other
branch of the if stmt (out of context)
sets the same variable to NULL via VIR_FREE.

>From afdb7b085d276c76d24468492045a7fc006022aa Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@xxxxxxxxxx>
Date: Wed, 4 Feb 2009 17:44:24 +0100
Subject: [PATCH] remove useless code

* src/bridge.c (brAddTap): Remove redundant errno=ENOMEM assignment
after failed strdup.
* src/cgroup.c (virCgroupFree): Remove redundant *group=NULL assignment
after VIR_FREE(*group).
* src/lxc_driver.c (lxcShutdown): Likewise.
* src/xen_unified.c (xenUnifiedClose): Likewise.
* src/xm_internal.c (xenXMDomainConfigFormat): Likewise, twice.
---
 src/bridge.c      |    6 ++----
 src/cgroup.c      |    1 -
 src/lxc_driver.c  |    1 -
 src/xen_unified.c |    1 -
 src/xm_internal.c |    3 ---
 5 files changed, 2 insertions(+), 10 deletions(-)

diff --git a/src/bridge.c b/src/bridge.c
index 9c4ca74..990a567 100644
--- a/src/bridge.c
+++ b/src/bridge.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007 Red Hat, Inc.
+ * Copyright (C) 2007, 2009 Red Hat, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -539,10 +539,8 @@ brAddTap(brControl *ctl,
             if ((errno = brSetInterfaceUp(ctl, try.ifr_name, 1)))
                 goto error;
             VIR_FREE(*ifname);
-            if (!(*ifname = strdup(try.ifr_name))) {
-                errno = ENOMEM;
+            if (!(*ifname = strdup(try.ifr_name)))
                 goto error;
-            }
             *tapfd = fd;
             return 0;
         }
diff --git a/src/cgroup.c b/src/cgroup.c
index 1b4c27f..8bd6e87 100644
--- a/src/cgroup.c
+++ b/src/cgroup.c
@@ -51,7 +51,6 @@ void virCgroupFree(virCgroupPtr *group)
     if (*group != NULL) {
         VIR_FREE((*group)->path);
         VIR_FREE(*group);
-        *group = NULL;
     }
 }

diff --git a/src/lxc_driver.c b/src/lxc_driver.c
index 8786505..aa417a9 100644
--- a/src/lxc_driver.c
+++ b/src/lxc_driver.c
@@ -1238,7 +1238,6 @@ static int lxcShutdown(void)
     lxcDriverUnlock(lxc_driver);
     virMutexDestroy(&lxc_driver->lock);
     VIR_FREE(lxc_driver);
-    lxc_driver = NULL;

     return 0;
 }
diff --git a/src/xen_unified.c b/src/xen_unified.c
index eefdb6c..8e64f51 100644
--- a/src/xen_unified.c
+++ b/src/xen_unified.c
@@ -399,7 +399,6 @@ xenUnifiedClose (virConnectPtr conn)

     virMutexDestroy(&priv->lock);
     VIR_FREE(conn->privateData);
-    conn->privateData = NULL;

     return 0;
 }
diff --git a/src/xm_internal.c b/src/xm_internal.c
index a03263c..c1e9e99 100644
--- a/src/xm_internal.c
+++ b/src/xm_internal.c
@@ -2239,8 +2239,6 @@ virConfPtr xenXMDomainConfigFormat(virConnectPtr conn,
         diskVal = NULL;
         goto no_memory;
     }
-    diskVal = NULL;
-

     if (VIR_ALLOC(netVal) < 0)
         goto no_memory;
@@ -2259,7 +2257,6 @@ virConfPtr xenXMDomainConfigFormat(virConnectPtr conn,
         netVal = NULL;
         goto no_memory;
     }
-    netVal = NULL;

     if (hvm) {
         if (def->nparallels) {
--
1.6.1.2.467.g081e7

--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[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]