From: Dave Chinner <david@fromorbit.com>
To: Jan Tulak <jtulak@redhat.com>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH 3/6 v2] mkfs: remove intermediate getstr followed by getnum
Date: Thu, 17 Aug 2017 21:36:47 +1000 [thread overview]
Message-ID: <20170817113647.GT21024@dastard> (raw)
In-Reply-To: <20170815150812.32237-2-jtulak@redhat.com>
On Tue, Aug 15, 2017 at 05:08:09PM +0200, Jan Tulak wrote:
> Some options loaded a number as a string with getstr and converted it to
> number with getnum later in the code, without any reason for this
> approach. (They were probably forgotten in some past cleaning.)
Ah, no. That was done very intentionally.
> @@ -1672,7 +1674,7 @@ main(
> xi.dname = getstr(value, &dopts, D_NAME);
> break;
> case D_SIZE:
> - dsize = getstr(value, &dopts, D_SIZE);
> + dbytes = getnum(value, &dopts, D_SIZE);
> break;
At this point here, the size can be specified in filesystem blocks
or sectors. We don't know what those sizes are yet - they might be
given to us later on the CLI so haven't been parsed yet.
Hence we can't convert from a string to a number yet, because the
units to do the conversion aren't defined.
Same goes for all the other 3 sizes that use strings.
> @@ -2254,10 +2255,7 @@ _("rmapbt not supported with realtime devices\n"));
> }
>
>
> - if (dsize) {
> - uint64_t dbytes;
> -
> - dbytes = getnum(dsize, &dopts, D_SIZE);
> + if (dbytes) {
> if (dbytes % XFS_MIN_BLOCKSIZE) {
> fprintf(stderr,
> _("illegal data length %lld, not a multiple of %d\n"),
By this time, we've validated the command line provided block/sector
sizes or have used and validated the default size. Hence we can now
convert from a string to a number as all the units we need are
defined.
IOWs, changing this code will break "size=XXXb" and "size=XXXs" CLI
size specification in unexpected ways.
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
next prev parent reply other threads:[~2017-08-17 11:36 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-11 12:30 [PATCH 0/6 v2] mkfs: save user input into opts table Jan Tulak
2017-08-11 12:30 ` [PATCH 1/6] mkfs: Save raw user input field to the opts struct Jan Tulak
2017-08-14 22:56 ` Darrick J. Wong
2017-08-15 9:47 ` Jan Tulak
2017-08-11 12:30 ` [PATCH 2/6] mkfs: rename defaultval to flagval in opts Jan Tulak
2017-08-14 22:56 ` Darrick J. Wong
2017-08-11 12:30 ` [PATCH 3/6] mkfs: remove intermediate getstr followed by getnum Jan Tulak
2017-08-14 22:58 ` Darrick J. Wong
2017-08-11 12:30 ` [PATCH 4/6] mkfs: merge tables for opts parsing into one table Jan Tulak
2017-08-14 23:06 ` Darrick J. Wong
2017-08-15 10:05 ` Jan Tulak
2017-08-11 12:30 ` [PATCH 5/6] mkfs: move getnum within the file Jan Tulak
2017-08-14 23:07 ` Darrick J. Wong
2017-08-15 10:14 ` Jan Tulak
2017-08-15 21:09 ` Eric Sandeen
2017-08-16 9:25 ` Jan Tulak
2017-08-11 12:30 ` [PATCH 6/6] mkfs: extend opt_params with a value field Jan Tulak
2017-08-14 23:15 ` Darrick J. Wong
2017-08-15 10:42 ` Jan Tulak
2017-08-15 15:08 ` [PATCH 1/6 v2] mkfs: Save raw user input field to the opts struct Jan Tulak
2017-08-15 15:08 ` [PATCH 3/6 v2] mkfs: remove intermediate getstr followed by getnum Jan Tulak
2017-08-15 23:20 ` Eric Sandeen
2017-08-17 11:36 ` Dave Chinner [this message]
2017-08-15 15:08 ` [PATCH 4/6 v2] mkfs: merge tables for opts parsing into one table Jan Tulak
2017-08-15 15:08 ` [PATCH 5/6 v2] mkfs: move getnum within the file Jan Tulak
2017-08-15 15:08 ` [PATCH 6/6 v2] mkfs: extend opt_params with a value field Jan Tulak
2017-08-16 21:13 ` Eric Sandeen
2017-08-16 21:38 ` Darrick J. Wong
2017-08-17 10:08 ` Jan Tulak
2017-08-17 11:03 ` Dave Chinner
2017-08-17 14:56 ` Jan Tulak
2017-08-17 22:59 ` Dave Chinner
2017-08-17 15:26 ` Eric Sandeen
2017-08-15 23:07 ` [PATCH 1/6 v2] mkfs: Save raw user input field to the opts struct Eric Sandeen
2017-08-16 9:11 ` Jan Tulak
2017-08-16 14:42 ` Eric Sandeen
2017-08-16 15:38 ` Jan Tulak
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=20170817113647.GT21024@dastard \
--to=david@fromorbit.com \
--cc=jtulak@redhat.com \
--cc=linux-xfs@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