lib/sign: convert ostree_sign_summary to new style
The "new style" code generally avoids `goto err` because it conflicts with `__attribute__((cleanup))`. This fixes a compiler warning. Signed-off-by: Denis Pynkin <denis.pynkin@collabora.com>
This commit is contained in:
parent
1e3bdef285
commit
e16faa58f4
|
|
@ -604,37 +604,32 @@ ostree_sign_summary (OstreeSign *self,
|
||||||
g_return_val_if_fail (OSTREE_IS_SIGN (self), FALSE);
|
g_return_val_if_fail (OSTREE_IS_SIGN (self), FALSE);
|
||||||
g_return_val_if_fail (OSTREE_IS_REPO (repo), FALSE);
|
g_return_val_if_fail (OSTREE_IS_REPO (repo), FALSE);
|
||||||
|
|
||||||
gboolean ret = FALSE;
|
|
||||||
|
|
||||||
g_autoptr(GVariant) normalized = NULL;
|
g_autoptr(GVariant) normalized = NULL;
|
||||||
g_autoptr(GBytes) summary_data = NULL;
|
g_autoptr(GBytes) summary_data = NULL;
|
||||||
g_autoptr(GVariant) metadata = NULL;
|
g_autoptr(GVariant) metadata = NULL;
|
||||||
|
|
||||||
glnx_autofd int fd = -1;
|
glnx_autofd int fd = -1;
|
||||||
if (!glnx_openat_rdonly (repo->repo_dir_fd, "summary", TRUE, &fd, error))
|
if (!glnx_openat_rdonly (repo->repo_dir_fd, "summary", TRUE, &fd, error))
|
||||||
goto out;
|
return FALSE;
|
||||||
summary_data = ot_fd_readall_or_mmap (fd, 0, error);
|
summary_data = ot_fd_readall_or_mmap (fd, 0, error);
|
||||||
if (!summary_data)
|
if (!summary_data)
|
||||||
goto out;
|
return FALSE;
|
||||||
|
|
||||||
/* Note that fd is reused below */
|
/* Note that fd is reused below */
|
||||||
glnx_close_fd (&fd);
|
glnx_close_fd (&fd);
|
||||||
|
|
||||||
if (!ot_openat_ignore_enoent (repo->repo_dir_fd, "summary.sig", &fd, error))
|
if (!ot_openat_ignore_enoent (repo->repo_dir_fd, "summary.sig", &fd, error))
|
||||||
goto out;
|
return FALSE;
|
||||||
|
|
||||||
if (fd >= 0)
|
if (fd >= 0)
|
||||||
{
|
{
|
||||||
if (!ot_variant_read_fd (fd, 0, OSTREE_SUMMARY_SIG_GVARIANT_FORMAT,
|
if (!ot_variant_read_fd (fd, 0, OSTREE_SUMMARY_SIG_GVARIANT_FORMAT,
|
||||||
FALSE, &metadata, error))
|
FALSE, &metadata, error))
|
||||||
goto out;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_variant_n_children(keys) == 0)
|
if (g_variant_n_children(keys) == 0)
|
||||||
{
|
return glnx_throw (error, "No keys passed for signing summary");
|
||||||
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
|
||||||
"No keys passed for signing summary");
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
GVariantIter *iter;
|
GVariantIter *iter;
|
||||||
GVariant *key;
|
GVariant *key;
|
||||||
|
|
@ -645,14 +640,14 @@ ostree_sign_summary (OstreeSign *self,
|
||||||
g_autoptr (GBytes) signature = NULL;
|
g_autoptr (GBytes) signature = NULL;
|
||||||
|
|
||||||
if (!ostree_sign_set_sk (self, key, error))
|
if (!ostree_sign_set_sk (self, key, error))
|
||||||
goto out;
|
return FALSE;
|
||||||
|
|
||||||
if (!ostree_sign_data (self,
|
if (!ostree_sign_data (self,
|
||||||
summary_data,
|
summary_data,
|
||||||
&signature,
|
&signature,
|
||||||
cancellable,
|
cancellable,
|
||||||
error))
|
error))
|
||||||
goto out;
|
return FALSE;
|
||||||
|
|
||||||
g_autoptr(GVariant) old_metadata = g_steal_pointer (&metadata);
|
g_autoptr(GVariant) old_metadata = g_steal_pointer (&metadata);
|
||||||
metadata =
|
metadata =
|
||||||
|
|
@ -667,10 +662,7 @@ ostree_sign_summary (OstreeSign *self,
|
||||||
g_variant_get_data (normalized),
|
g_variant_get_data (normalized),
|
||||||
g_variant_get_size (normalized),
|
g_variant_get_size (normalized),
|
||||||
cancellable, error))
|
cancellable, error))
|
||||||
goto out;
|
return FALSE;
|
||||||
|
|
||||||
ret = TRUE;
|
return TRUE;
|
||||||
|
|
||||||
out:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue