[PATCH 07/19] mkfs: structify input parameter passing
Jan Tulak
jtulak at redhat.com
Thu Apr 7 06:43:12 CDT 2016
On Thu, Apr 7, 2016 at 5:14 AM, Eric Sandeen <sandeen at sandeen.net> wrote:
>
> > + * minval, maxval OPTIONAL
> > + * These options are used for automatic range check and they have
> to be
> > + * always used together in pair. If you don't want to limit the max
> value,
> > + * use something like UINT_MAX. If no value is given, then you
> either has
>
> then you must either supply your own validation, or ...
>
> > + * to supply your own validation, or refuse any value in the 'case
> > + * X_SOMETHING' block. If you forget to pass a min or max value
> here, but
>
> forget to define a min and max value (?)
>
> > + * call a standard function for validating user's value, it will
> cause an
> > + * error message notifying you about this issue.
> > + *
> > + * (Said in another way, you can't have minval and maxval both equal
> > + * to zero. But if one value is different: minval=0 and maxval=1,
> > + * then it is OK.)
>
> I think that makes sense ... by the time I got to the end of this I was a
> little confused. ;)
>
> So you don't have to define min/max, but if you call getnum_checked(), then
> min & max are required, and they can't both be zero - is that correct?
>
Yes. I couldn't find any usecase, where an option would accept only single
hardcoded value (0, in this case) as an argument, and nothing else, because
then it doesn't need the argument at all...
And because forgetting the min/maxval is easy (I know it first hand :-) ),
I added the check for minval==0 && maxval == 0 to raise an error if you
call getnum_checked() for this option.
Cheers,
Jan
--
Jan Tulak
jtulak at redhat.com / jan at tulak.me
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://oss.sgi.com/pipermail/xfs/attachments/20160407/390395a4/attachment.html>
More information about the xfs
mailing list