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

index 70e35ae..e0e9a2f 100644 (file)
@@ -364,12 +364,12 @@ static int remove_attribute(struct osl_table *table, struct osl_row *row,
        ret = get_attribute_bitnum_by_name(name, &red.bitnum);
        if (ret < 0) {
                para_printf(&raad->pb, "%s: %s\n", name, para_strerror(-ret));
-               return 0;
+               return ret;
        }
        ret = osl(osl_del_row(table, row));
        if (ret < 0) {
                para_printf(&raad->pb, "%s: %s\n", name, para_strerror(-ret));
-               return 0;
+               return ret;
        }
        para_printf(&raad->pb, "removed attribute %s\n", name);
        raad->num_removed++;
@@ -401,25 +401,23 @@ static int com_rmatt_callback(int fd, const struct osl_object *query)
                .action = remove_attribute
        };
        ret = for_each_matching_row(&pmd);
-       if (ret < 0)
+       if (ret < 0) {
                para_printf(&raad.pb, "%s\n", para_strerror(-ret));
-       else if (!raad.num_removed)
-               para_printf(&raad.pb, "no match -- nothing removed\n");
+               goto out;
+       }
+       if (!raad.num_removed)
+               ret = -E_NO_MATCH;
+out:
        flush_and_free_pb(&raad.pb);
-       return 0;
+       return ret;
 }
 
 int com_rmatt(struct command_context *cc)
 {
-       int ret;
-
        if (cc->argc < 2)
                return -E_ATTR_SYNTAX;
-       ret = send_standard_callback_request(cc->argc - 1, cc->argv + 1,
+       return send_standard_callback_request(cc->argc - 1, cc->argv + 1,
                com_rmatt_callback, afs_cb_result_handler, cc);
-       if (ret < 0)
-               send_strerror(cc, -ret);
-       return ret;
 }
 
 /**