[libvirt PATCH] Remove unused variables

Ján Tomko posted 1 patch 3 years, 8 months ago
Test syntax-check failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/d1d0ff387cdaf44b36eaad0010049a971db66d09.1596454791.git.jtomko@redhat.com
src/conf/domain_conf.c  | 4 +---
src/util/virdevmapper.c | 3 +--
2 files changed, 2 insertions(+), 5 deletions(-)
[libvirt PATCH] Remove unused variables
Posted by Ján Tomko 3 years, 8 months ago
These variables are only used for assignment and have
no other effect.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
---
Found by clang-analyzer. Just install the package with scan-build and
run:
  ninja -C build scan-build

(or some meson --reconfigure might be necessary.
 OTOH, I did not get ninja coverage to work so far.)

 src/conf/domain_conf.c  | 4 +---
 src/util/virdevmapper.c | 3 +--
 2 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index fd8cdb7695..69e0439e7e 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -8857,8 +8857,6 @@ virDomainHostdevDefParseXMLCaps(xmlNodePtr node G_GNUC_UNUSED,
                                 const char *type,
                                 virDomainHostdevDefPtr def)
 {
-    xmlNodePtr sourcenode;
-
     /* @type is passed in from the caller rather than read from the
      * xml document, because it is specified in different places for
      * different kinds of defs - it is an attribute of
@@ -8881,7 +8879,7 @@ virDomainHostdevDefParseXMLCaps(xmlNodePtr node G_GNUC_UNUSED,
         return -1;
     }
 
-    if (!(sourcenode = virXPathNode("./source", ctxt))) {
+    if (!virXPathNode("./source", ctxt)) {
         virReportError(VIR_ERR_XML_ERROR, "%s",
                        _("Missing <source> element in hostdev device"));
         return -1;
diff --git a/src/util/virdevmapper.c b/src/util/virdevmapper.c
index a471504176..fe7f611496 100644
--- a/src/util/virdevmapper.c
+++ b/src/util/virdevmapper.c
@@ -162,7 +162,6 @@ virDMSanitizepath(const char *path)
     DIR *dh = NULL;
     const char *p;
     char *ret = NULL;
-    int rc;
 
     /* If a path is NOT provided then assume it's DM name */
     p = strrchr(path, '/');
@@ -192,7 +191,7 @@ virDMSanitizepath(const char *path)
     if (virDirOpen(&dh, DEV_DM_DIR) < 0)
         return NULL;
 
-    while ((rc = virDirRead(dh, &ent, DEV_DM_DIR)) > 0) {
+    while (virDirRead(dh, &ent, DEV_DM_DIR) > 0) {
         g_autofree char *tmp = g_strdup_printf(DEV_DM_DIR "/%s", ent->d_name);
 
         if (stat(tmp, &sb[1]) == 0 &&
-- 
2.26.2

Re: [libvirt PATCH] Remove unused variables
Posted by Pavel Hrdina 3 years, 8 months ago
On Mon, Aug 03, 2020 at 01:42:00PM +0200, Ján Tomko wrote:
> These variables are only used for assignment and have
> no other effect.
> 
> Signed-off-by: Ján Tomko <jtomko@redhat.com>
> ---
> Found by clang-analyzer. Just install the package with scan-build and
> run:
>   ninja -C build scan-build
> 
> (or some meson --reconfigure might be necessary.
>  OTOH, I did not get ninja coverage to work so far.)
> 
>  src/conf/domain_conf.c  | 4 +---
>  src/util/virdevmapper.c | 3 +--
>  2 files changed, 2 insertions(+), 5 deletions(-)

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>