Re: Checkpatch.pl false positive? "ERROR: return is not afunction, parentheses are not required"

From: Joe Perches
Date: Sun Mar 28 2010 - 15:59:36 EST


On Sun, 2010-03-28 at 23:09 +0300, Alexey Dobriyan wrote:
> On Sun, Mar 28, 2010 at 10:28:13PM +0300, Olimpiu Pascariu wrote:
> > return (dt3155_fbuffer[m]->ready_head -
> > dt3155_fbuffer[m]->ready_len +
> > dt3155_fbuffer[m]->nbuffers)%
> > (dt3155_fbuffer[m]->nbuffers);
> > IMHO the code is correct, though an auxiliary variable could be used to
> > avoid this error returned by checkpatch.pl.
> Yes, checkpatch.pl doesn't understand C.

And as currently implemented, can not.

I think this passes checkpatch without warning:

return (dt3155_fbuffer[m]->ready_head -
dt3155_fbuffer[m]->ready_len +
dt3155_fbuffer[m]->nbuffers) %
dt3155_fbuffer[m]->nbuffers;

It might be better to use a temporary for dt3155_fbuffer[m]
so the code could look more like:
return (p->ready_head - p->ready_len + p->nbuffers) % p->nbuffers;


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/