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>
const char *data)
{
char *configFile;
+ int ret = -1;
if (!(configFile = virFileBuildPath(configDir, name, ".base64")))
return -1;
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;
}