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

Re: [Libvir] Repository for work-in-progress storage patches



"Daniel P. Berrange" <berrange redhat com> wrote:
>     hg qclone -p http://hg.berrange.com/libraries/libvirt--storage \
>                  http://hg.berrange.com/libraries/libvirt--devel

Relative to a snapshot of a few minutes ago, here are two patches:

	* src/storage_backend_fs.c (virStorageBackendFileSystemVolCreate):
	Save a 4KB memset.
	* src/storage_backend_iscsi.c (virStorageBackendISCSIStablePath):
	Don't leak a directory handle in failure paths.

Signed-off-by: Jim Meyering <meyering redhat com>
---
 src/storage_backend_fs.c    |    3 +--
 src/storage_backend_iscsi.c |    7 +++++--
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/storage_backend_fs.c b/src/storage_backend_fs.c
index 9e75114..ee17087 100644
--- a/src/storage_backend_fs.c
+++ b/src/storage_backend_fs.c
@@ -606,8 +606,7 @@ static int virStorageBackendFileSystemVolCreate(virConnectPtr conn,
         /* XXX slooooooooooooooooow. Need to add in progress bars & bg thread somehow */
         if (vol->allocation) {
             unsigned long long remain = vol->allocation;
-            char zeros[4096];
-            memset(zeros, 0, sizeof(zeros));
+            static const char const zeros[4096];
             while (remain) {
                 int bytes = sizeof(zeros);
                 if (bytes > remain)
diff --git a/src/storage_backend_iscsi.c b/src/storage_backend_iscsi.c
index 00dd40c..bbc1608 100644
--- a/src/storage_backend_iscsi.c
+++ b/src/storage_backend_iscsi.c
@@ -38,7 +38,7 @@
 #include "util.h"

 static int virStorageBackendISCSITargetIP(virConnectPtr conn,
-                                          char *hostname,
+                                          const char *hostname,
                                           char *ipaddr,
                                           size_t ipaddrlen)
 {
@@ -184,6 +184,7 @@ static char *virStorageBackendISCSIStablePath(virConnectPtr conn,
         stablepath = malloc(strlen(pool->def->target.path) + 1 + strlen(dent->d_name) + 1);
         if (stablepath == NULL) {
             virStorageReportError(conn, VIR_ERR_NO_MEMORY, "path");
+            closedir(dh);
             return NULL;
         }

@@ -191,8 +192,10 @@ static char *virStorageBackendISCSIStablePath(virConnectPtr conn,
         strcat(stablepath, "/");
         strcat(stablepath, dent->d_name);

-        if (virFileLinkPointsTo(stablepath, devpath))
+        if (virFileLinkPointsTo(stablepath, devpath)) {
+            closedir(dh);
             return stablepath;
+        }

         free(stablepath);
     }
--
1.5.4.rc4.1.g1895


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