lib/sign: convert ostree_sign_summary to new style
authorDenis Pynkin <denis.pynkin@collabora.com>
Mon, 17 Feb 2020 21:50:21 +0000 (00:50 +0300)
committerDenis Pynkin <denis.pynkin@collabora.com>
Wed, 25 Mar 2020 12:23:55 +0000 (15:23 +0300)
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>
src/libostree/ostree-sign.c

index 23ec84ee0cc9563b493fa2e7e1163e11f770690e..c96f751fc29ad2c3e1cb3e5ea7ac77c3e5ec322b 100644 (file)
@@ -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_REPO (repo), FALSE);
 
-  gboolean ret = FALSE;
-
   g_autoptr(GVariant) normalized = NULL;
   g_autoptr(GBytes) summary_data = NULL;
   g_autoptr(GVariant) metadata = NULL;
 
   glnx_autofd int fd = -1;
   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);
   if (!summary_data)
-    goto out;
+    return FALSE;
 
   /* Note that fd is reused below */
   glnx_close_fd (&fd);
 
   if (!ot_openat_ignore_enoent (repo->repo_dir_fd, "summary.sig", &fd, error))
-    goto out;
+    return FALSE;
+
   if (fd >= 0)
     {
       if (!ot_variant_read_fd (fd, 0, OSTREE_SUMMARY_SIG_GVARIANT_FORMAT,
                                FALSE, &metadata, error))
-        goto out;
+        return FALSE;
     }
 
   if (g_variant_n_children(keys) == 0)
-    {
-      g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
-                           "No keys passed for signing summary");
-      goto out;
-    }
+    return glnx_throw (error, "No keys passed for signing summary");
 
   GVariantIter *iter;
   GVariant *key;
@@ -645,14 +640,14 @@ ostree_sign_summary (OstreeSign    *self,
       g_autoptr (GBytes) signature = NULL;
 
       if (!ostree_sign_set_sk (self, key, error))
-        goto out;
+        return FALSE;
 
       if (!ostree_sign_data (self,
                              summary_data,
                              &signature,
                              cancellable,
                              error))
-        goto out;
+        return FALSE;
 
       g_autoptr(GVariant) old_metadata = g_steal_pointer (&metadata);
       metadata =
@@ -667,10 +662,7 @@ ostree_sign_summary (OstreeSign    *self,
                                            g_variant_get_data (normalized),
                                            g_variant_get_size (normalized),
                                            cancellable, error))
-    goto out;
-
-  ret = TRUE;
+    return FALSE;
 
-out:
-  return ret;
+  return TRUE;
 }