On Thu, Apr 29, 2021 at 09:31:57AM -0700, Greg Steuck wrote:
> Alexander Bluhm <[email protected]> writes:
> >> I like this too. I somehow got the impression that macros are severely
> >> frowned upon and didn't offer this kind of interface before.
> >>
> >> If you get this submitted, I can do a pass through the codebase to be
> >> sure we catch them all.
>
> Vitaliy, I volunteer to do a separate pass, no reason to gate this clear
> improvement.
Ok :)
>
> Q: would the introduction of SYSCTL_BOOL be considered an improvement
> over "0, 1"?
>
> > Anyone who wants to OK it?
>
> OK gnezdo, nits inline.
>
> >
> > +int
> > +sysctl_int_bounded(void *oldp, size_t *oldlenp, void *newp, size_t newlen,
> > + int *valp, int minimum, int maximum)
> > +{
> > + int val = *valp;
> > + int error;
> > +
> > + /* read only */
> > + if (newp == NULL || minimum > maximum)
> > + return (sysctl_rdint(oldp, oldlenp, newp, *valp));
>
> + return (sysctl_rdint(oldp, oldlenp, newp, val));
>
> This would make valp be used exactly to read and write the
> variable. Seems a tiny bit simpler.
>
Agreed, this seems reasonable.
> > diff -u -p -r1.214 sysctl.h
> > --- sys/sysctl.h 10 Mar 2021 10:21:47 -0000 1.214
> > +++ sys/sysctl.h 28 Apr 2021 10:04:02 -0000
> > @@ -1000,6 +1000,9 @@ struct sysctl_bounded_args {
> > int maximum; /* read-only variable if minimum > maximum */
> > };
> >
> > +#define SYSCTL_INT_UNBOUNDED 0,0
>
> Unused, maybe introduce a single usage as an example?
>
Or introduce this with the separate diff which will convert all related
structures?
Anyway diff is OK by me.