From: Andre Noll Date: Sun, 5 Apr 2015 13:19:48 +0000 (+0000) Subject: com_cpsi(): Return negative on errors X-Git-Tag: v0.5.6~94^2~22 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=4bdac4f11551a124d2e0e5b43cf6aeda3b8c5c71;p=paraslash.git com_cpsi(): Return negative on errors --- diff --git a/aft.c b/aft.c index bfee23d9..96e0ab9a 100644 --- a/aft.c +++ b/aft.c @@ -2310,23 +2310,23 @@ static int com_cpsi_callback(int fd, const struct osl_object *query) if (ret < 0) goto out; ret = for_each_matching_row(&pmd); -out: if (ret < 0) - para_printf(&cad.pb, "%s\n", para_strerror(-ret)); - else if (pmd.num_matches > 0) { + goto out; + if (pmd.num_matches > 0) { if (cad.flags & CPSI_FLAG_VERBOSE) - para_printf(&cad.pb, "copied requested afsi from %s " - "to %u files\n", source_path, pmd.num_matches); + para_printf(&cad.pb, "updated afsi of %u file(s)\n", + pmd.num_matches); } else - para_printf(&cad.pb, "no matches - nothing copied\n"); + ret = -E_NO_MATCH; +out: flush_and_free_pb(&cad.pb); - return 0; + return ret; } int com_cpsi(struct command_context *cc) { unsigned flags = 0; - int i, ret; + int i; struct osl_object options = {.data = &flags, .size = sizeof(flags)}; for (i = 1; i < cc->argc; i++) { @@ -2367,11 +2367,8 @@ int com_cpsi(struct command_context *cc) return -E_AFT_SYNTAX; if (!(flags & ~CPSI_FLAG_VERBOSE)) /* no copy flags given */ flags = ~(unsigned)CPSI_FLAG_VERBOSE | flags; - ret = send_option_arg_callback_request(&options, cc->argc - i, + return send_option_arg_callback_request(&options, cc->argc - i, cc->argv + i, com_cpsi_callback, afs_cb_result_handler, cc); - if (ret < 0) - send_strerror(cc, -ret); - return ret; } struct change_atts_data {