From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: sandeen@redhat.com
Cc: linux-xfs@vger.kernel.org
Subject: [PATCH 6/2] mkfs: always explain why numeric inputs are invalid
Date: Mon, 29 Jan 2018 19:39:22 -0800 [thread overview]
Message-ID: <20180130033922.GN9068@magnolia> (raw)
In-Reply-To: <151692412532.32390.5360363880930671862.stgit@magnolia>
From: Darrick J. Wong <darrick.wong@oracle.com>
Always explain why invalid numeric inputs are not valid, and in a
complete sentence since that's what illegal_optio() sets us up for.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
mkfs/xfs_mkfs.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index 6285b24..f527476 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -1269,7 +1269,7 @@ illegal_option(
fprintf(stderr,
_("Invalid value %s for -%c %s option. %s\n"),
value, opts->name, opts->subopts[index],
- reason ? reason : "");
+ reason);
usage();
}
@@ -1360,18 +1360,20 @@ getnum(
c = strtoll(str, &str_end, 0);
if (c == 0 && str_end == str)
- illegal_option(str, opts, index, NULL);
+ illegal_option(str, opts, index,
+ _("Value not recognized as number."));
if (*str_end != '\0')
- illegal_option(str, opts, index, NULL);
+ illegal_option(str, opts, index,
+ _("Unit suffixes are not allowed."));
}
/* Validity check the result. */
if (c < sp->minval)
- illegal_option(str, opts, index, _("value is too small"));
+ illegal_option(str, opts, index, _("Value is too small."));
else if (c > sp->maxval)
- illegal_option(str, opts, index, _("value is too large"));
+ illegal_option(str, opts, index, _("Value is too large."));
if (sp->is_power_2 && !ispow2(c))
- illegal_option(str, opts, index, _("value must be a power of 2"));
+ illegal_option(str, opts, index, _("Value must be a power of 2."));
return c;
}
next prev parent reply other threads:[~2018-01-30 3:39 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-25 23:48 [PATCH 0/2] xfsprogs: 4.15 rollup pt. 3 Darrick J. Wong
2018-01-25 23:48 ` [PATCH 1/2] xfs_db: print transaction reservation type information Darrick J. Wong
2018-01-25 23:48 ` [PATCH 2/2] xfs_db: interpret inode timestamps as signed integers Darrick J. Wong
2018-01-30 16:46 ` Eric Sandeen
2018-01-26 18:14 ` [PATCH 3/2] misc: ubsan fixes Darrick J. Wong
2018-01-30 16:47 ` Eric Sandeen
2018-01-30 3:38 ` [PATCH 4/2] mkfs: don't crash on dswidth overflow Darrick J. Wong
2018-01-30 3:54 ` Eric Sandeen
2018-01-30 3:38 ` [PATCH 5/2] mkfs: don't call values 'illegal', they're invalid Darrick J. Wong
2018-01-30 3:55 ` Eric Sandeen
2018-01-30 3:39 ` Darrick J. Wong [this message]
2018-01-30 3:57 ` [PATCH 6/2] mkfs: always explain why numeric inputs are invalid Eric Sandeen
2018-01-30 4:13 ` [PATCH 7/2] mkfs: more sunit/swidth sanity checking Eric Sandeen
2018-01-30 16:48 ` Darrick J. Wong
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=20180130033922.GN9068@magnolia \
--to=darrick.wong@oracle.com \
--cc=linux-xfs@vger.kernel.org \
--cc=sandeen@redhat.com \
/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