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

[libvirt] three more clang-inspired dead-store-fixing patches



>From a2d03c987bb724283207dbeef873178c08a6c4c5 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering redhat com>
Date: Thu, 3 Sep 2009 18:14:48 +0200
Subject: [PATCH 1/3] storage_backend_logical.c: appease clang: remove useless increment

* src/storage_backend_logical.c (virStorageBackendLogicalBuildPool):
Don't increment "n" when we won't use the result.
---
 src/storage_backend_logical.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/storage_backend_logical.c b/src/storage_backend_logical.c
index bc40dd7..43117e8 100644
--- a/src/storage_backend_logical.c
+++ b/src/storage_backend_logical.c
@@ -437,7 +437,7 @@ virStorageBackendLogicalBuildPool(virConnectPtr conn,
             goto cleanup;
     }

-    vgargv[n++] = NULL;
+    vgargv[n] = NULL;

     /* Now create the volume group itself */
     if (virRun(conn, vgargv, NULL) < 0)
--
1.6.4.2.395.ge3d52


>From b72ed1ba5d5e6444f000fd9be706a51a90dd2292 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering redhat com>
Date: Thu, 3 Sep 2009 18:23:51 +0200
Subject: [PATCH 2/3] openvz_conf.c: Remove dead store to copy_fd

* src/openvz_conf.c (openvz_copyfile): Remove unused assignment.
---
 src/openvz_conf.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/src/openvz_conf.c b/src/openvz_conf.c
index 41c6684..2f0471c 100644
--- a/src/openvz_conf.c
+++ b/src/openvz_conf.c
@@ -692,7 +692,6 @@ openvz_copyfile(char* from_path, char* to_path)
     fd = -1;
     if (close(copy_fd) < 0)
         goto error;
-    copy_fd = -1;

     return 0;

--
1.6.4.2.395.ge3d52


>From a8d2eca13635578084e3c2cc2093562d9a8fcfed Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering redhat com>
Date: Thu, 3 Sep 2009 18:25:03 +0200
Subject: [PATCH 3/3] eventtest.c: detect write failure and avoid dead stores

* tests/eventtest.c (mymain): Exit nonzero upon write failure.
This also avoids several dead stores of the form ret = safewrite...
---
 tests/eventtest.c |   15 +++++++++------
 1 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/tests/eventtest.c b/tests/eventtest.c
index d25381d..ef37ff1 100644
--- a/tests/eventtest.c
+++ b/tests/eventtest.c
@@ -248,7 +248,6 @@ resetAll(void)
 static int
 mymain(int argc, char **argv)
 {
-    int ret = 0;
     char *progname;
     int i;
     pthread_t eventThread;
@@ -304,7 +303,8 @@ mymain(int argc, char **argv)
     /* First time, is easy - just try triggering one of our
      * registered handles */
     startJob("Simple write", &test);
-    ret = safewrite(handles[1].pipeFD[1], &one, 1);
+    if (safewrite(handles[1].pipeFD[1], &one, 1) != 1)
+        return EXIT_FAILURE;
     if (finishJob(1, -1) != EXIT_SUCCESS)
         return EXIT_FAILURE;

@@ -314,7 +314,8 @@ mymain(int argc, char **argv)
      * try triggering another handle */
     virEventRemoveHandleImpl(handles[0].watch);
     startJob("Deleted before poll", &test);
-    ret = safewrite(handles[1].pipeFD[1], &one, 1);
+    if (safewrite(handles[1].pipeFD[1], &one, 1) != 1)
+        return EXIT_FAILURE;
     if (finishJob(1, -1) != EXIT_SUCCESS)
         return EXIT_FAILURE;

@@ -346,8 +347,9 @@ mymain(int argc, char **argv)
      * about */
     startJob("Deleted during dispatch", &test);
     handles[2].delete = handles[3].watch;
-    ret = safewrite(handles[2].pipeFD[1], &one, 1);
-    ret = safewrite(handles[3].pipeFD[1], &one, 1);
+    if (safewrite(handles[2].pipeFD[1], &one, 1) != 1
+        || safewrite(handles[3].pipeFD[1], &one, 1) != 1)
+        return EXIT_FAILURE;
     if (finishJob(2, -1) != EXIT_SUCCESS)
         return EXIT_FAILURE;

@@ -356,7 +358,8 @@ mymain(int argc, char **argv)
     /* Extreme fun, lets delete ourselves during dispatch */
     startJob("Deleted during dispatch", &test);
     handles[2].delete = handles[2].watch;
-    ret = safewrite(handles[2].pipeFD[1], &one, 1);
+    if (safewrite(handles[2].pipeFD[1], &one, 1) != 1)
+        return EXIT_FAILURE;
     if (finishJob(2, -1) != EXIT_SUCCESS)
         return EXIT_FAILURE;

--
1.6.4.2.395.ge3d52


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