From 74a8dbbc3e501680865a8bc96a991297de6438d5 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Sun, 5 Apr 2015 12:59:22 +0000 Subject: [PATCH] com_touch(): Return negative on errors --- aft.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/aft.c b/aft.c index 8573c200..b79d7076 100644 --- a/aft.c +++ b/aft.c @@ -1974,12 +1974,12 @@ static int touch_audio_file(__a_unused struct osl_table *table, ret = get_afsi_object_of_row(row, &obj); if (ret < 0) { - para_printf(&tad->pb, "%s: %s\n", name, para_strerror(-ret)); + para_printf(&tad->pb, "cannot touch %s\n", name); return ret; } ret = load_afsi(&old_afsi, &obj); if (ret < 0) { - para_printf(&tad->pb, "%s: %s\n", name, para_strerror(-ret)); + para_printf(&tad->pb, "cannot touch %s\n", name); return ret; } new_afsi = old_afsi; @@ -2036,12 +2036,10 @@ static int com_touch_callback(int fd, const struct osl_object *query) if (tad.cto->flags & TOUCH_FLAG_FNM_PATHNAME) pmd.fnmatch_flags |= FNM_PATHNAME; ret = for_each_matching_row(&pmd); - if (ret < 0) - para_printf(&tad.pb, "%s\n", para_strerror(-ret)); - else if (pmd.num_matches == 0) - para_printf(&tad.pb, "no matches\n"); + if (ret >= 0 && pmd.num_matches == 0) + ret = -E_NO_MATCH; flush_and_free_pb(&tad.pb); - return 0; + return ret; } int com_touch(struct command_context *cc) @@ -2111,11 +2109,8 @@ int com_touch(struct command_context *cc) } if (i >= cc->argc) return -E_AFT_SYNTAX; - ret = send_option_arg_callback_request(&query, cc->argc - i, + return send_option_arg_callback_request(&query, cc->argc - i, cc->argv + i, com_touch_callback, afs_cb_result_handler, cc); - if (ret < 0) - send_strerror(cc, -ret); - return ret; } /** Flags for com_rm(). */ -- 2.39.5