From 767ca134b55ee057fd2100ae44c3adafb64854d9 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Tue, 22 Aug 2023 17:49:28 -0400 Subject: [PATCH 1/2] cmd/init: Port to C99 style Just keeping up momentum. --- src/ostree/ot-builtin-init.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/ostree/ot-builtin-init.c b/src/ostree/ot-builtin-init.c index 379c2b989d..114f9baab0 100644 --- a/src/ostree/ot-builtin-init.c +++ b/src/ostree/ot-builtin-init.c @@ -46,26 +46,21 @@ gboolean ostree_builtin_init (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error) { - g_autoptr (GOptionContext) context = NULL; - g_autoptr (OstreeRepo) repo = NULL; - gboolean ret = FALSE; - OstreeRepoMode mode; - - context = g_option_context_new (""); + g_autoptr (GOptionContext) context = g_option_context_new (""); + g_autoptr (OstreeRepo) repo = NULL; if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable, error)) - goto out; + return FALSE; + OstreeRepoMode mode; if (!ostree_repo_mode_from_string (opt_mode, &mode, error)) - goto out; + return FALSE; if (!ostree_repo_set_collection_id (repo, opt_collection_id, error)) - goto out; + return FALSE; if (!ostree_repo_create (repo, mode, NULL, error)) - goto out; + return FALSE; - ret = TRUE; -out: - return ret; + return TRUE; } From 75a43deb306e602b6e96d971ea305e7f62ac2355 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Tue, 22 Aug 2023 17:51:33 -0400 Subject: [PATCH 2/2] cmd/grub2-generate: Port to C99 style Just keeping up momentum. --- ...ot-admin-instutil-builtin-grub2-generate.c | 26 +++++-------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/src/ostree/ot-admin-instutil-builtin-grub2-generate.c b/src/ostree/ot-admin-instutil-builtin-grub2-generate.c index 0f8a8636e5..e73ffa148a 100644 --- a/src/ostree/ot-admin-instutil-builtin-grub2-generate.c +++ b/src/ostree/ot-admin-instutil-builtin-grub2-generate.c @@ -33,28 +33,21 @@ ot_admin_instutil_builtin_grub2_generate (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error) { - gboolean ret = FALSE; - guint bootversion; - g_autoptr (GOptionContext) context = NULL; - g_autoptr (OstreeSysroot) sysroot = NULL; - - context = g_option_context_new ("[BOOTVERSION]"); + g_autoptr (GOptionContext) context = g_option_context_new ("[BOOTVERSION]"); + g_autoptr (OstreeSysroot) sysroot = NULL; if (!ostree_admin_option_context_parse (context, options, &argc, &argv, OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER | OSTREE_ADMIN_BUILTIN_FLAG_UNLOCKED, invocation, &sysroot, cancellable, error)) - goto out; + return FALSE; + guint bootversion; if (argc >= 2) { bootversion = (guint)g_ascii_strtoull (argv[1], NULL, 10); if (!(bootversion == 0 || bootversion == 1)) - { - g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Invalid bootversion: %u", - bootversion); - goto out; - } + return glnx_throw (error, "Invalid bootversion: %u", bootversion); } else { @@ -66,11 +59,6 @@ ot_admin_instutil_builtin_grub2_generate (int argc, char **argv, g_assert (bootversion == 0 || bootversion == 1); } - if (!ostree_cmd__private__ ()->ostree_generate_grub2_config (sysroot, bootversion, 1, cancellable, - error)) - goto out; - - ret = TRUE; -out: - return ret; + return ostree_cmd__private__ ()->ostree_generate_grub2_config (sysroot, bootversion, 1, + cancellable, error); }