[libvirt] [PATCH 07/10] qemuProcessSEVCreateFile: use a cleanup label

Ján Tomko jtomko at redhat.com
Tue Jun 12 12:00:21 UTC 2018


A common cleanup path for both the success and the error case.

Signed-off-by: Ján Tomko <jtomko at redhat.com>
---
 src/qemu/qemu_process.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 5d4b6a9499..7468e14447 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -5831,6 +5831,7 @@ qemuProcessSEVCreateFile(const char *configDir,
                          const char *data)
 {
     char *configFile;
+    int ret = -1;
 
     if (!(configFile = virFileBuildPath(configDir, name, ".base64")))
         return -1;
@@ -5838,15 +5839,12 @@ qemuProcessSEVCreateFile(const char *configDir,
     if (virFileRewriteStr(configFile, S_IRUSR | S_IWUSR, data) < 0) {
         virReportSystemError(errno, _("failed to write data to config '%s'"),
                              configFile);
-        goto error;
+        goto cleanup;
     }
 
+ cleanup:
     VIR_FREE(configFile);
-    return 0;
-
- error:
-    VIR_FREE(configFile);
-    return -1;
+    return ret;
 }
 
 
-- 
2.16.1




More information about the libvir-list mailing list