Re: [PATCH] fs/compat: remove redundant 'less than zero' check

Dan Carpenter
2015-04-24T13:00:29Z

On Fri, Apr 24, 2015 at 02:23:23PM +0200, Julia Lawall wrote:
> On Fri, 24 Apr 2015, Dan Carpenter wrote:
>
> > On Fri, Apr 24, 2015 at 06:07:50PM +0800, Firo Yang wrote:
> >
> > > - if (nr_segs > UIO_MAXIOV || nr_segs < 0)
> > > + if (nr_segs > UIO_MAXIOV)
> >
> > Linus said at kernel summit that he thinks this kind of checks are ok.
> >
> > Smatch already ignores checks like:
> >
> > if (nr_segs < 0 || nr_segs > UIO_MAXIOV)
> >
> > So making it ignore this one as well shouldn't be hard... I'll change
> > Smatch to ignore this one as well.
>
> It is unsigned. What is the point of cluttering the code?

I guess I don't feel strongly either way. It was Linus who said
something like "the intent is clear from the code" so he isn't a fan of
these particular static checker fixes.

These are easy enough for me to filter out so they needn't cause a false
positive.

They're more of a style issue than anything else. With coccinelle, it's
easier to care about style issues because you can fix them automatically.
In Smatch caring about style issues is a time suck.

regards,
dan carpenter