* mu-cmd: fix gboolean vs MuExitCode confusion

This commit is contained in:
Dirk-Jan C. Binnema
2011-08-09 07:52:55 +03:00
parent 2c26c4dca2
commit a3b627f866

View File

@ -162,12 +162,12 @@ view_msg_plain (MuMsg *msg, const gchar *fields, gboolean summary,
} }
static MuExitCode static gboolean
handle_msg (const char *fname, MuConfig *opts) handle_msg (const char *fname, MuConfig *opts, MuExitCode *code)
{ {
GError *err; GError *err;
MuMsg *msg; MuMsg *msg;
MuExitCode rv; gboolean rv;
err = NULL; err = NULL;
msg = mu_msg_new_from_file (fname, NULL, &err); msg = mu_msg_new_from_file (fname, NULL, &err);
@ -175,7 +175,8 @@ handle_msg (const char *fname, MuConfig *opts)
if (!msg) { if (!msg) {
g_warning ("error: %s", err->message); g_warning ("error: %s", err->message);
g_error_free (err); g_error_free (err);
return MU_EXITCODE_ERROR; *code = MU_EXITCODE_ERROR;
return FALSE;
} }
switch (opts->format) { switch (opts->format) {
@ -187,7 +188,8 @@ handle_msg (const char *fname, MuConfig *opts)
break; break;
default: default:
g_critical ("bug: should not be reached"); g_critical ("bug: should not be reached");
rv = MU_EXITCODE_ERROR; *code = MU_EXITCODE_ERROR;
rv = FALSE;
} }
mu_msg_unref (msg); mu_msg_unref (msg);
@ -221,7 +223,9 @@ view_params_valid (MuConfig *opts)
MuExitCode MuExitCode
mu_cmd_view (MuConfig *opts) mu_cmd_view (MuConfig *opts)
{ {
int rv, i; int i;
gboolean rv;
MuExitCode code;
g_return_val_if_fail (opts, MU_EXITCODE_ERROR); g_return_val_if_fail (opts, MU_EXITCODE_ERROR);
g_return_val_if_fail (opts->cmd == MU_CONFIG_CMD_VIEW, g_return_val_if_fail (opts->cmd == MU_CONFIG_CMD_VIEW,
@ -230,17 +234,17 @@ mu_cmd_view (MuConfig *opts)
if (!view_params_valid(opts)) if (!view_params_valid(opts))
return MU_EXITCODE_ERROR; return MU_EXITCODE_ERROR;
for (i = 1; opts->params[i]; ++i) { for (i = 1, code = MU_EXITCODE_OK; opts->params[i]; ++i) {
rv = handle_msg (opts->params[i], opts); rv = handle_msg (opts->params[i], opts, &code);
if (rv != MU_EXITCODE_OK) if (!rv)
break; break;
/* add a separator between two messages? */ /* add a separator between two messages? */
if (opts->terminator) if (opts->terminator)
g_print ("%c", VIEW_TERMINATOR); g_print ("%c", VIEW_TERMINATOR);
} }
return rv; return code;
} }
@ -364,7 +368,7 @@ check_file_okay (const char *path, gboolean cmd_add)
} }
static MuExitCode static gboolean
add_or_remove (MuConfig *opts, gboolean cmd_add) add_or_remove (MuConfig *opts, gboolean cmd_add)
{ {
MuStore *store; MuStore *store;