From: Andre Noll <maan@tuebingen.mpg.de>
Date: Sun, 5 Apr 2015 22:21:56 +0000 (+0000)
Subject: com_rmatt(): Return negative on errors
X-Git-Tag: v0.5.6~94^2~16
X-Git-Url: https://git.tue.mpg.de/?a=commitdiff_plain;h=46456d9c78c489708f63f5d44894e42f137dd535;p=paraslash.git

com_rmatt(): Return negative on errors
---

diff --git a/attribute.c b/attribute.c
index 70e35ae5..e0e9a2fa 100644
--- a/attribute.c
+++ b/attribute.c
@@ -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;
 }
 
 /**