xfs
[Top] [All Lists]

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

To: Eric Sandeen <sandeen@xxxxxxxxxxx>
Subject: Re: [PATCH 07/19] mkfs: structify input parameter passing
From: Jan Tulak <jtulak@xxxxxxxxxx>
Date: Thu, 7 Apr 2016 13:43:12 +0200
Cc: xfs-oss <xfs@xxxxxxxxxxx>
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <5705D0AD.9060106@xxxxxxxxxxx>
References: <1458818136-56043-1-git-send-email-jtulak@xxxxxxxxxx> <1458818136-56043-8-git-send-email-jtulak@xxxxxxxxxx> <5705D0AD.9060106@xxxxxxxxxxx>
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â

--
<Prev in Thread] Current Thread [Next in Thread>