com_touch(): Return negative on errors
authorAndre Noll <maan@tuebingen.mpg.de>
Sun, 5 Apr 2015 12:59:22 +0000 (12:59 +0000)
committerAndre Noll <maan@tuebingen.mpg.de>
Wed, 12 Aug 2015 21:23:47 +0000 (23:23 +0200)
aft.c

diff --git a/aft.c b/aft.c
index 8573c20..b79d707 100644 (file)
--- 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(). */