[PATCH] storageBackendCreatePloop: Refactor cleanup

Yi Li posted 1 patch 3 years, 3 months ago
Test syntax-check failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20210108061422.3141235-1-yili@winhong.com
src/storage/storage_util.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
[PATCH] storageBackendCreatePloop: Refactor cleanup
Posted by Yi Li 3 years, 3 months ago
get rid of the 'cleanup:' label and created variable.

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

diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c
index 2478cb0a4a..2e2c7dc68a 100644
--- a/src/storage/storage_util.c
+++ b/src/storage/storage_util.c
@@ -563,7 +563,6 @@ storageBackendCreatePloop(virStoragePoolObjPtr pool G_GNUC_UNUSED,
                           unsigned int flags)
 {
     int ret = -1;
-    bool created = false;
     g_autoptr(virCommand) cmd = NULL;
     g_autofree char *create_tool = NULL;
 
@@ -607,7 +606,7 @@ storageBackendCreatePloop(virStoragePoolObjPtr pool G_GNUC_UNUSED,
                           0)) < 0) {
             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                            _("error creating directory for ploop volume"));
-            goto cleanup;
+            return -1;
         }
         cmd = virCommandNewArgList(create_tool, "init", "-s", NULL);
         virCommandAddArgFormat(cmd, "%lluM", VIR_DIV_UP(vol->target.capacity,
@@ -620,10 +619,8 @@ storageBackendCreatePloop(virStoragePoolObjPtr pool G_GNUC_UNUSED,
         cmd = virCommandNewArgList("cp", "-r", inputvol->target.path,
                                    vol->target.path, NULL);
     }
-    created = true;
     ret = virCommandRun(cmd, NULL);
- cleanup:
-    if (ret < 0 && created)
+    if (ret < 0)
         virFileDeleteTree(vol->target.path);
     return ret;
 }
-- 
2.25.3




Re: [PATCH] storageBackendCreatePloop: Refactor cleanup
Posted by Ján Tomko 3 years, 3 months ago
On a Friday in 2021, Yi Li wrote:
>get rid of the 'cleanup:' label and created variable.
>

I changed this to:
Get rid of the 'cleanup' label and 'created' variable.

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

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

Jano