]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemuProcessSEVCreateFile: use a cleanup label
authorJán Tomko <jtomko@redhat.com>
Tue, 12 Jun 2018 11:39:42 +0000 (13:39 +0200)
committerJán Tomko <jtomko@redhat.com>
Thu, 14 Jun 2018 07:04:51 +0000 (09:04 +0200)
A common cleanup path for both the success and the error case.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Brijesh Singh <brijesh.singh@amd.com>
Tested-by: Brijesh Singh <brijesh.singh@amd.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
src/qemu/qemu_process.c

index 965d7a48f040f606aafc2e35a940cdd037fb320e..faa6915c2547f0845d3453107200011c282985ef 100644 (file)
@@ -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;
 }