Re: Repository for work-in-progress storage patches

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

 



"Daniel P. Berrange" <berrange@xxxxxxxxxx> 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@xxxxxxxxxx>
---
 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

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