core: Skip an unnecessary unlink() call

This commit is contained in:
Colin Walters 2011-11-18 09:41:36 -05:00
parent 7276e2df43
commit 8621eb85b1
1 changed files with 5 additions and 3 deletions

View File

@ -607,21 +607,23 @@ write_gvariant_to_tmp (OstreeRepo *self,
ot_util_set_error_from_errno (error, errno); ot_util_set_error_from_errno (error, errno);
goto out; goto out;
} }
g_free (tmp_name);
tmp_name = NULL;
ret = TRUE; ret = TRUE;
*out_tmpname = ot_gfile_new_for_path (dest_name); *out_tmpname = ot_gfile_new_for_path (dest_name);
*out_checksum = checksum; *out_checksum = checksum;
checksum = NULL; checksum = NULL;
out: out:
/* Unconditionally unlink; if we suceeded, there's a new link, if not, clean up. */ if (tmp_name)
(void) unlink (tmp_name); (void) unlink (tmp_name);
g_free (tmp_name);
if (fd != -1) if (fd != -1)
close (fd); close (fd);
if (checksum) if (checksum)
g_checksum_free (checksum); g_checksum_free (checksum);
if (serialized != NULL) if (serialized != NULL)
g_variant_unref (serialized); g_variant_unref (serialized);
g_free (tmp_name);
g_free (dest_name); g_free (dest_name);
g_clear_object (&stream); g_clear_object (&stream);
return ret; return ret;