X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=aft.c;h=0207705f858a3beb77c98a6a7e0e6a2c123e68b6;hp=bfee23d9790ba6b10b115edfbdf01ff72cc23a39;hb=b605df7dcee2c6e642a141aea24e643eb6ca34ec;hpb=b02b7155f01bbe802883e4085b93f146e06cc386 diff --git a/aft.c b/aft.c index bfee23d9..0207705f 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 { @@ -2461,12 +2458,10 @@ static int com_setatt_callback(int fd, const struct osl_object *query) if (ret < 0) goto out; if (pmd.num_matches == 0) - para_printf(&cad.pb, "no matches\n"); + ret = -E_NO_MATCH; out: - if (ret < 0) - para_printf(&cad.pb, "%s\n", para_strerror(-ret)); flush_and_free_pb(&cad.pb); - return 0; + return ret; } int com_setatt(struct command_context *cc) @@ -2511,7 +2506,7 @@ int send_afs_status(struct command_context *cc, int parser_friendly) afs_cb_result_handler, cc); } -/* returns success even on errors to keep the loop going */ +/* returns success on non-fatal errors to keep the loop going */ static int check_audio_file(struct osl_row *row, void *data) { char *path; @@ -2523,7 +2518,7 @@ static int check_audio_file(struct osl_row *row, void *data) if (ret < 0) { para_printf(pb, "%s\n", para_strerror(-ret)); - return 0; + return ret; } if (stat(path, &statbuf) < 0) para_printf(pb, "%s: stat error (%s)\n", path, strerror(errno)); @@ -2551,12 +2546,13 @@ static int check_audio_file(struct osl_row *row, void *data) * \param fd The afs socket. * \param query Unused. * - * \return This function always returns zero. + * \return Standard. Inconsistencies are reported but not regarded as an error. * * \sa com_check(). */ int aft_check_callback(int fd, __a_unused const struct osl_object *query) { + int ret; struct para_buffer pb = { .max_size = shm_get_shmmax(), .private_data = &(struct afs_max_size_handler_data) { @@ -2566,9 +2562,9 @@ int aft_check_callback(int fd, __a_unused const struct osl_object *query) .max_size_handler = afs_max_size_handler }; para_printf(&pb, "checking audio file table...\n"); - audio_file_loop(&pb, check_audio_file); + ret = audio_file_loop(&pb, check_audio_file); flush_and_free_pb(&pb); - return 0; + return ret; } /**