[libvirt] [PATCH] storage: Don't get src in each loop since src is not changed

李义 posted 1 patch 2 weeks ago
Failed in applying to current master (apply log)
src/storage/storage_backend_fs.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)

[libvirt] [PATCH] storage: Don't get src in each loop since src is not changed

Posted by 李义 2 weeks ago
The src of pool is not changed in each loop,
so don't VIR_FREE(src) and get when next iteration.

Signed-off-by: Yi Li <yili@winhong.com>
---
 src/storage/storage_backend_fs.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c
index 02b8248..27c1098 100644
--- a/src/storage/storage_backend_fs.c
+++ b/src/storage/storage_backend_fs.c
@@ -258,10 +258,10 @@
virStorageBackendFileSystemIsMounted(virStoragePoolObjPtr pool)
         goto cleanup;
     }

-    while ((getmntent_r(mtab, &ent, buf, sizeof(buf))) != NULL) {
-        if (!(src = virStorageBackendFileSystemGetPoolSource(pool)))
-            goto cleanup;
+    if ((src = virStorageBackendFileSystemGetPoolSource(pool)) == NULL)
+        goto cleanup;

+    while ((getmntent_r(mtab, &ent, buf, sizeof(buf))) != NULL) {
         /* compare both mount destinations and sources to be sure the mounted
          * FS pool is really the one we're looking for
          */
@@ -273,8 +273,6 @@
virStorageBackendFileSystemIsMounted(virStoragePoolObjPtr pool)
             ret = 1;
             goto cleanup;
         }
-
-        VIR_FREE(src);
     }

     ret = 0;

--
2.7.5

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

Re: [libvirt] [PATCH] storage: Don't get src in each loop since src is not changed

Posted by Ján Tomko 3 days ago
On Fri, Nov 01, 2019 at 03:34:25PM +0800, 李义 wrote:
>The src of pool is not changed in each loop,
>so don't VIR_FREE(src) and get when next iteration.
>
>Signed-off-by: Yi Li <yili@winhong.com>
>---
> src/storage/storage_backend_fs.c | 8 +++-----
> 1 file changed, 3 insertions(+), 5 deletions(-)
>

Code-wise this looks correct, but the first version had a better commit
message (and most importantly, the From: field and Signed-off-by: fields
matched), so I combined them together and pushed.:
https://www.redhat.com/archives/libvir-list/2019-October/msg01867.html


>diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c
>index 02b8248..27c1098 100644
>--- a/src/storage/storage_backend_fs.c
>+++ b/src/storage/storage_backend_fs.c
>@@ -258,10 +258,10 @@
>virStorageBackendFileSystemIsMounted(virStoragePoolObjPtr pool)
>         goto cleanup;
>     }
>
>-    while ((getmntent_r(mtab, &ent, buf, sizeof(buf))) != NULL) {
>-        if (!(src = virStorageBackendFileSystemGetPoolSource(pool)))
>-            goto cleanup;
>+    if ((src = virStorageBackendFileSystemGetPoolSource(pool)) == NULL)
>+        goto cleanup;
>
>+    while ((getmntent_r(mtab, &ent, buf, sizeof(buf))) != NULL) {
>         /* compare both mount destinations and sources to be sure the mounted
>          * FS pool is really the one we're looking for
>          */
>@@ -273,8 +273,6 @@
>virStorageBackendFileSystemIsMounted(virStoragePoolObjPtr pool)
>             ret = 1;
>             goto cleanup;
>         }
>-
>-        VIR_FREE(src);
>     }
>
>     ret = 0;
>

Reviewed-by: Ján Tomko <jtomko@redhat.com>

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