From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH 1/3] btrfs-progs: utils-lib: Use error() to replace fprintf(stderr, "ERROR: ")
Date: Mon, 21 Oct 2019 17:37:53 +0800 [thread overview]
Message-ID: <20191021093755.56835-2-wqu@suse.com> (raw)
In-Reply-To: <20191021093755.56835-1-wqu@suse.com>
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(-)
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;
--
2.23.0
next prev parent reply other threads:[~2019-10-21 9:38 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-21 9:37 [PATCH 0/3] btrfs-progs: check: Introduce optional argument for -b|--backup Qu Wenruo
2019-10-21 9:37 ` Qu Wenruo [this message]
2019-10-21 9:48 ` [PATCH 1/3] btrfs-progs: utils-lib: Use error() to replace fprintf(stderr, "ERROR: ") Johannes Thumshirn
2019-10-21 9:37 ` [PATCH 2/3] btrfs-progs: disk-io: Handle backup root more correctly Qu Wenruo
2019-10-21 9:37 ` [PATCH 3/3] btrfs-progs: check: Introduce optional argument for -b|--backup Qu Wenruo
2019-11-15 12:32 ` [PATCH 0/3] " David Sterba
2019-11-15 12:36 ` Qu Wenruo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191021093755.56835-2-wqu@suse.com \
--to=wqu@suse.com \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox