diff --git a/src/ostree/ot-builtin-config.c b/src/ostree/ot-builtin-config.c index 913ed66d..8e00af08 100644 --- a/src/ostree/ot-builtin-config.c +++ b/src/ostree/ot-builtin-config.c @@ -65,23 +65,22 @@ ostree_builtin_config (int argc, char **argv, OstreeCommandInvocation *invocatio { g_autoptr(GOptionContext) context = NULL; g_autoptr(OstreeRepo) repo = NULL; - gboolean ret = FALSE; const char *op; const char *section_key; const char *value; g_autofree char *section = NULL; g_autofree char *key = NULL; - GKeyFile *config = NULL; + g_autoptr(GKeyFile) config = NULL; context = g_option_context_new ("(get KEY|set KEY VALUE|unset KEY)"); if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable, error)) - goto out; + return FALSE; if (argc < 2) { ot_util_usage_error (context, "OPERATION must be specified", error); - goto out; + return FALSE; } op = argv[1]; @@ -94,7 +93,7 @@ ostree_builtin_config (int argc, char **argv, OstreeCommandInvocation *invocatio { g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "GROUP name, KEY and VALUE must be specified"); - goto out; + return FALSE; } section = g_strdup(opt_group); key = g_strdup(argv[2]); @@ -106,19 +105,19 @@ ostree_builtin_config (int argc, char **argv, OstreeCommandInvocation *invocatio { g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "KEY and VALUE must be specified"); - goto out; + return FALSE; } section_key = argv[2]; value = argv[3]; if(!split_key_string (section_key, §ion, &key, error)) - goto out; + return FALSE; } config = ostree_repo_copy_config (repo); g_key_file_set_string (config, section, key, value); if (!ostree_repo_write_config (repo, config, error)) - goto out; + return FALSE; } else if (!strcmp (op, "get")) { @@ -130,7 +129,7 @@ ostree_builtin_config (int argc, char **argv, OstreeCommandInvocation *invocatio { g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Group name and key must be specified"); - goto out; + return FALSE; } section = g_strdup(opt_group); key = g_strdup(argv[2]); @@ -141,17 +140,17 @@ ostree_builtin_config (int argc, char **argv, OstreeCommandInvocation *invocatio { g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "KEY must be specified"); - goto out; + return FALSE; } section_key = argv[2]; if (!split_key_string (section_key, §ion, &key, error)) - goto out; + return FALSE; } readonly_config = ostree_repo_get_config (repo); value = g_key_file_get_string (readonly_config, section, key, error); if (value == NULL) - goto out; + return FALSE; g_print ("%s\n", value); } @@ -164,7 +163,7 @@ ostree_builtin_config (int argc, char **argv, OstreeCommandInvocation *invocatio { g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Group name and key must be specified"); - goto out; + return FALSE; } section = g_strdup(opt_group); key = g_strdup(argv[2]); @@ -175,11 +174,11 @@ ostree_builtin_config (int argc, char **argv, OstreeCommandInvocation *invocatio { g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "KEY must be specified"); - goto out; + return FALSE; } section_key = argv[2]; if (!split_key_string (section_key, §ion, &key, error)) - goto out; + return FALSE; } config = ostree_repo_copy_config (repo); @@ -189,23 +188,19 @@ ostree_builtin_config (int argc, char **argv, OstreeCommandInvocation *invocatio !g_error_matches (local_error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_GROUP_NOT_FOUND)) { g_propagate_error (error, g_steal_pointer (&local_error)); - goto out; + return FALSE; } } if (local_error == NULL && !ostree_repo_write_config (repo, config, error)) - goto out; + return FALSE; } else { g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Unknown operation %s", op); - goto out; + return FALSE; } - ret = TRUE; - out: - if (config) - g_key_file_free (config); - return ret; + return TRUE; }