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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Apr 7, 2016 at 5:14 AM, Eric Sandeen <sandeen@xxxxxxxxxxx> 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​

--
_______________________________________________
xfs mailing list
xfs@xxxxxxxxxxx
http://oss.sgi.com/mailman/listinfo/xfs

[Index of Archives]     [Linux XFS Devel]     [Linux Filesystem Development]     [Filesystem Testing]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux