From 40f490ed11febb72182b125c67a86b5f634211b6 Mon Sep 17 00:00:00 2001 From: "Owen W. Taylor" Date: Tue, 23 Sep 2014 11:58:27 -0400 Subject: [PATCH] ostree admin: Fix return value from 'ostree admin [instutil]' 'ostree admin' and 'ostree admin instuil' with no arguments were meant to fail, but the logic was wrong; add an assertion on the return value from all ostree commands to catch similar problems in the future. https://bugzilla.gnome.org/show_bug.cgi?id=737194 --- src/ostree/ot-admin-builtin-instutil.c | 8 +++++++- src/ostree/ot-builtin-admin.c | 8 +++++++- src/ostree/ot-main.c | 10 +++++++++- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/ostree/ot-admin-builtin-instutil.c b/src/ostree/ot-admin-builtin-instutil.c index 0a6bb315..66ea80ed 100644 --- a/src/ostree/ot-admin-builtin-instutil.c +++ b/src/ostree/ot-admin-builtin-instutil.c @@ -127,7 +127,13 @@ ot_admin_builtin_instutil (int argc, char **argv, OstreeSysroot *sysroot, GCance g_print (" %s\n", subcommand->name); subcommand++; } - return subcommand_name == NULL ? 1 : 0; + + if (want_help) + ret = TRUE; + else + g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED, + "No command specified"); + goto out; } subcommand = admin_instutil_subcommands; diff --git a/src/ostree/ot-builtin-admin.c b/src/ostree/ot-builtin-admin.c index f7dce93a..6db97ca4 100644 --- a/src/ostree/ot-builtin-admin.c +++ b/src/ostree/ot-builtin-admin.c @@ -155,7 +155,13 @@ ostree_builtin_admin (int argc, char **argv, OstreeRepo *repo, GCancellable *can g_print (" %s\n", subcommand->name); subcommand++; } - return subcommand_name == NULL ? 1 : 0; + + if (want_help) + ret = TRUE; + else + g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED, + "No command specified"); + goto out; } subcommand = admin_subcommands; diff --git a/src/ostree/ot-main.c b/src/ostree/ot-main.c index 1dfa93d7..6adb2d22 100644 --- a/src/ostree/ot-main.c +++ b/src/ostree/ot-main.c @@ -83,6 +83,7 @@ ostree_run (int argc, const char *repo_arg = NULL; gboolean want_help = FALSE; gboolean skip; + gboolean success = FALSE; int in, out, i; /* avoid gvfs (http://bugzilla.gnome.org/show_bug.cgi?id=526454) */ @@ -191,7 +192,11 @@ ostree_run (int argc, if (cmd == NULL) { - if (!want_help) + if (want_help) + { + success = TRUE; + } + else { g_set_error_literal (&error, G_IO_ERROR, G_IO_ERROR_FAILED, "No command specified"); @@ -252,7 +257,10 @@ ostree_run (int argc, if (!command->fn (argc, argv, repo, cancellable, &error)) goto out; + success = TRUE; out: + g_assert (success || error); + if (error) { g_propagate_error (res_error, error);