occtl: propagate error codes on error conditions.

This commit is contained in:
Nikos Mavrogiannopoulos
2014-05-11 14:19:07 +02:00
parent 522a9c35a4
commit ed0cb777dd
2 changed files with 11 additions and 5 deletions

View File

@@ -651,7 +651,6 @@ int common_info_cmd(UserListRep * args)
if (print_list_entries(out, "\tiRoutes:", args->user[i]->iroutes, args->user[i]->n_iroutes) < 0)
goto error_parse;
at_least_one = 1;
}
@@ -662,8 +661,10 @@ int common_info_cmd(UserListRep * args)
fprintf(stderr, "%s: message parsing error\n", __func__);
goto cleanup;
cleanup:
if (at_least_one == 0)
if (at_least_one == 0) {
fprintf(out, "user or ID not found\n");
ret = 2;
}
pager_stop(out);
return ret;
@@ -701,7 +702,6 @@ int handle_show_user_cmd(struct unix_ctx *ctx, const char *arg)
if (ret < 0)
goto error;
ret = 0;
goto cleanup;
error:
@@ -751,7 +751,6 @@ int handle_show_id_cmd(struct unix_ctx *ctx, const char *arg)
if (ret < 0)
goto error;
ret = 0;
goto cleanup;
error:

View File

@@ -280,8 +280,15 @@ unsigned check_cmd(const char *cmd, const char *input,
while (whitespace(*p))
p++;
if (need_preconn == 0 || conn_prehandle(conn) >= 0)
if (need_preconn != 0) {
if (conn_prehandle(conn) < 0) {
*status = 1;
} else {
*status = func(conn, p);
}
} else {
*status = func(conn, p);
}
ret = 1;