]> git.tue.mpg.de Git - paraslash.git/commitdiff
com_lsatt(): Return negative on errors
authorAndre Noll <maan@tuebingen.mpg.de>
Sun, 5 Apr 2015 13:49:10 +0000 (13:49 +0000)
committerAndre Noll <maan@tuebingen.mpg.de>
Wed, 12 Aug 2015 21:23:48 +0000 (23:23 +0200)
attribute.c

index 7da525eb90c7f6feef5a8af631e2be06e4b38dca..82ac4dac87226fcc5482ea472574d9a486b62857 100644 (file)
@@ -151,6 +151,7 @@ static int print_attribute(struct osl_table *table, struct osl_row *row,
 
 static int com_lsatt_callback(int fd, const struct osl_object *query)
 {
+       int ret;
        struct lsatt_action_data laad = {
                .flags = *(unsigned *) query->data,
                .pb = {
@@ -177,16 +178,21 @@ static int com_lsatt_callback(int fd, const struct osl_object *query)
                pmd.loop_col_num = ATTCOL_NAME;
        if (laad.flags & LSATT_FLAG_REVERSE)
                pmd.pm_flags |= PM_REVERSE_LOOP;
-       for_each_matching_row(&pmd);
+       ret = for_each_matching_row(&pmd);
+       if (ret < 0)
+               goto out;
+       if (pmd.num_matches == 0)
+               ret = -E_NO_MATCH;
+out:
        flush_and_free_pb(&laad.pb);
-       return 0;
+       return ret;
 }
 
 int com_lsatt(struct command_context *cc)
 {
        unsigned flags = 0;
        struct osl_object options = {.data = &flags, .size = sizeof(flags)};
-       int ret, i;
+       int i;
 
        for (i = 1; i < cc->argc; i++) {
                const char *arg = cc->argv[i];
@@ -209,13 +215,8 @@ int com_lsatt(struct command_context *cc)
                        continue;
                }
        }
-       ret = send_option_arg_callback_request(&options, cc->argc - i, cc->argv + i,
+       return send_option_arg_callback_request(&options, cc->argc - i, cc->argv + i,
                com_lsatt_callback, afs_cb_result_handler, cc);
-       if (ret < 0)
-               send_strerror(cc, -ret);
-       else if (ret == 0 && cc->argc > 1)
-               ret = send_sb_va(&cc->scc, SBD_ERROR_LOG, "no matches\n");
-       return ret;
 }
 
 struct addatt_event_data {