diff mbox series

[1/3] btrfs-progs: utils-lib: Use error() to replace fprintf(stderr, "ERROR: ")

Message ID 20191021093755.56835-2-wqu@suse.com (mailing list archive)
State New, archived
Headers show
Series btrfs-progs: check: Introduce optional argument for -b|--backup | expand

Commit Message

Qu Wenruo Oct. 21, 2019, 9:37 a.m. UTC
This saves several lines of code.

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 utils-lib.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

Comments

Johannes Thumshirn Oct. 21, 2019, 9:48 a.m. UTC | #1
Looks good,
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
diff mbox series

Patch

diff --git a/utils-lib.c b/utils-lib.c
index c2b6097f5df9..0202dd7677f0 100644
--- a/utils-lib.c
+++ b/utils-lib.c
@@ -23,8 +23,7 @@  u64 arg_strtou64(const char *str)
 
 	value = strtoull(str, &ptr_parse_end, 0);
 	if (ptr_parse_end && *ptr_parse_end != '\0') {
-		fprintf(stderr, "ERROR: %s is not a valid numeric value.\n",
-			str);
+		error("%s is not a valid numeric value.", str);
 		exit(1);
 	}
 
@@ -33,12 +32,11 @@  u64 arg_strtou64(const char *str)
 	 * unexpected number to us, so let's do the check ourselves.
 	 */
 	if (str[0] == '-') {
-		fprintf(stderr, "ERROR: %s: negative value is invalid.\n",
-			str);
+		error("%s: negative value is invalid.", str);
 		exit(1);
 	}
 	if (value == ULLONG_MAX) {
-		fprintf(stderr, "ERROR: %s is too large.\n", str);
+		error("%s is too large.", str);
 		exit(1);
 	}
 	return value;