Re: [PATCH 07/19] mkfs: structify input parameter passing

Jan Tulak
2016-04-07T11:43:37Z

[-- Attachment #1.1: Type: text/plain, Size: 1737 bytes --]

On Thu, Apr 7, 2016 at 5:14 AM, Eric Sandeen <sandeen@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@redhat.com / jan@tulak.me

[-- Attachment #1.2: Type: text/html, Size: 3346 bytes --]

[-- Attachment #2: Type: text/plain, Size: 121 bytes --]