* Checkpatch.pl false positive? "ERROR: return is not a function, parentheses are not required"
@ 2010-03-28 19:28 Olimpiu Pascariu
2010-03-28 20:09 ` Alexey Dobriyan
2010-09-02 13:44 ` Andy Whitcroft
0 siblings, 2 replies; 5+ messages in thread
From: Olimpiu Pascariu @ 2010-03-28 19:28 UTC (permalink / raw)
To: apw, akpm, dwalker, joe; +Cc: linux-kernel
Hi,
I've used checkpatch.pl to verify drivers/staging/dt3155/dt3155_isr.c,
in order to provide a patch which fixes the errors and warnings found by
checkpatch.
The script returns the following error:
ERROR: return is not a function, parentheses are not required
#155: FILE: staging/dt3155/dt3155_isr.c:155:
+ return (dt3155_fbuffer[m]->ready_head -
The original code is:
return (dt3155_fbuffer[m]->ready_head -
dt3155_fbuffer[m]->ready_len +
dt3155_fbuffer[m]->nbuffers)%
(dt3155_fbuffer[m]->nbuffers);
I've deleted the the first open parenthesis and the last close
parenthesis, and now the code looks like this:
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.
Regards,
Olimpiu Pascariu
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: Checkpatch.pl false positive? "ERROR: return is not a function, parentheses are not required"
2010-03-28 19:28 Checkpatch.pl false positive? "ERROR: return is not a function, parentheses are not required" Olimpiu Pascariu
@ 2010-03-28 20:09 ` Alexey Dobriyan
2010-03-28 19:59 ` Joe Perches
2010-09-02 13:44 ` Andy Whitcroft
1 sibling, 1 reply; 5+ messages in thread
From: Alexey Dobriyan @ 2010-03-28 20:09 UTC (permalink / raw)
To: Olimpiu Pascariu; +Cc: apw, akpm, dwalker, joe, linux-kernel
On Sun, Mar 28, 2010 at 10:28:13PM +0300, Olimpiu Pascariu wrote:
> I've used checkpatch.pl to verify drivers/staging/dt3155/dt3155_isr.c,
> in order to provide a patch which fixes the errors and warnings found by
> checkpatch.
> The script returns the following error:
> ERROR: return is not a function, parentheses are not required
> #155: FILE: staging/dt3155/dt3155_isr.c:155:
> + return (dt3155_fbuffer[m]->ready_head -
>
> The original code is:
>
> return (dt3155_fbuffer[m]->ready_head -
> dt3155_fbuffer[m]->ready_len +
> dt3155_fbuffer[m]->nbuffers)%
> (dt3155_fbuffer[m]->nbuffers);
>
> I've deleted the the first open parenthesis and the last close
> parenthesis, and now the code looks like this:
>
> 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.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Checkpatch.pl false positive? "ERROR: return is not a function, parentheses are not required"
2010-03-28 20:09 ` Alexey Dobriyan
@ 2010-03-28 19:59 ` Joe Perches
2010-03-28 20:56 ` Olimpiu Pascariu
0 siblings, 1 reply; 5+ messages in thread
From: Joe Perches @ 2010-03-28 19:59 UTC (permalink / raw)
To: Alexey Dobriyan; +Cc: Olimpiu Pascariu, apw, akpm, dwalker, linux-kernel
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;
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Checkpatch.pl false positive? "ERROR: return is not a function, parentheses are not required"
2010-03-28 19:28 Checkpatch.pl false positive? "ERROR: return is not a function, parentheses are not required" Olimpiu Pascariu
2010-03-28 20:09 ` Alexey Dobriyan
@ 2010-09-02 13:44 ` Andy Whitcroft
1 sibling, 0 replies; 5+ messages in thread
From: Andy Whitcroft @ 2010-09-02 13:44 UTC (permalink / raw)
To: Olimpiu Pascariu; +Cc: akpm, dwalker, joe, linux-kernel
On Sun, Mar 28, 2010 at 10:28:13PM +0300, Olimpiu Pascariu wrote:
> Hi,
>
> I've used checkpatch.pl to verify drivers/staging/dt3155/dt3155_isr.c,
> in order to provide a patch which fixes the errors and warnings found by
> checkpatch.
> The script returns the following error:
> ERROR: return is not a function, parentheses are not required
> #155: FILE: staging/dt3155/dt3155_isr.c:155:
> + return (dt3155_fbuffer[m]->ready_head -
>
> The original code is:
>
> return (dt3155_fbuffer[m]->ready_head -
> dt3155_fbuffer[m]->ready_len +
> dt3155_fbuffer[m]->nbuffers)%
> (dt3155_fbuffer[m]->nbuffers);
>
> I've deleted the the first open parenthesis and the last close
> parenthesis, and now the code looks like this:
>
> 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.
This code is indeed correct. This is a bug in checkpatch, I think I
have sorted out the bug in the version below (which should be mirrored
out shortly). If you could test the version below and let me know that
would be helpful:
http://www.kernel.org/pub/linux/kernel/people/apw/checkpatch/checkpatch.pl-testing
-apw
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-09-02 13:45 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-28 19:28 Checkpatch.pl false positive? "ERROR: return is not a function, parentheses are not required" Olimpiu Pascariu
2010-03-28 20:09 ` Alexey Dobriyan
2010-03-28 19:59 ` Joe Perches
2010-03-28 20:56 ` Olimpiu Pascariu
2010-09-02 13:44 ` Andy Whitcroft
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox