[PATCH 12/15] mkfs: merge getnum
Christoph Hellwig
hch at infradead.org
Mon Dec 2 11:22:33 CST 2013
On Fri, Nov 29, 2013 at 12:43:47PM +1100, Dave Chinner wrote:
> From: Dave Chinner <dchinner at redhat.com>
>
> getnum() is now only called by getnum_checked(). Move the two
> together into a single getnum() function and change all the callers
> back to getnum().
So we now have two different getnums in mkfs now. Maybe the one in
proto.c should have a different name?
> +static long long
> +getnum(
> + const char *str,
> + unsigned int blksize,
> + unsigned int sectsize,
> + bool convert)
> +{
> + long long i;
> + char *sp;
> +
> + if (convert)
> + return cvtnum(blksize, sectsize, str);
Also the whole if convert is true sillyness lives on here. The caller
that wants cvtnum should just call it directly.
> + else {
> + char *sp;
> +
> + c = strtoll(str, &sp, 0);
> + if (c == 0 && sp == str)
> + illegal_option(str, opts, index);
> + if (*sp != '\0')
> + illegal_option(str, opts, index);
> + }
And given that the strtoll wrapping code is the same for both getnums
I suspect we shoud just have a mkfs_strtoll that gets called here,
and directly by the proto.c callers.
More information about the xfs
mailing list