Closed
Bug 711480
Opened 14 years ago
Closed 14 years ago
malformed conditional in js/src/shell/js.cpp
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
RESOLVED
FIXED
mozilla12
People
(Reporter: julia.lawall, Assigned: dmandelin)
Details
User Agent: Mozilla/5.0 (Ubuntu; X11; Linux i686; rv:8.0) Gecko/20100101 Firefox/8.0
Build ID: 20111115183158
Steps to reproduce:
The following malformed conditional was found using Coccinelle (http://coccinelle.lip6.fr) in the file js/src/shell/js.cpp in the function ConvertArgs. The ; after the if test means that ReportException is always called.
if (!tmpstr || !func.encode(cx, tmpstr));
ReportException(cx);
Updated•14 years ago
|
Assignee: nobody → general
Component: General → JavaScript Engine
Product: Firefox → Core
QA Contact: general → general
Comment 1•14 years ago
|
||
Nice catch.
Some of the error-handling code in that method looks dodgy, but not enough to be sure that it's not that way intentionally so, so I'm not sure the obvious fix -- removing the ; -- is enough to be correct here.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Comment 2•14 years ago
|
||
Some compilers give a warning here -- this is a good one, worth error'ing on. SpiderMonkey house style uses continue; and not just ; to write empty loop bodies.
/be
Comment 3•14 years ago
|
||
Brendan, that's not even a loop -- just an if statement. I'm *really* not sure why compilers aren't warning about that.
Comment 4•14 years ago
|
||
GCC has -Wempty-body, which is enabled by -Wextra but not -Wall.
Comment 5•14 years ago
|
||
(In reply to Jeff Walden (remove +bmo to email) from comment #3)
> Brendan, that's not even a loop -- just an if statement.
Yes, I know -- it ought to be always an error.
> I'm *really* not sure why compilers aren't warning about that.
Walso, should comment 4 be spun out as a new owned bug? Or fixed here, whatever is best.
/be
![]() |
||
Comment 6•14 years ago
|
||
I'm going to add -Wempty-body in bug 711895.
Reporter | ||
Comment 7•14 years ago
|
||
There are about 50 empty-bodied ifs in ipc/chromium/src/base/third_party/purify/pure_api.c.
These all look intentional.
![]() |
||
Comment 8•14 years ago
|
||
(In reply to Julia Lawall from comment #7)
> There are about 50 empty-bodied ifs in
> ipc/chromium/src/base/third_party/purify/pure_api.c.
> These all look intentional.
Yes, but that file is only compiled on Windows so if you turn on -Wempty-body for GCC it doesn't matter. I only get two extra warnings when I turn it on for Linux64 debug builds, both in gfx/ycbcr/yuv_convert.cpp.
Assignee | ||
Comment 9•14 years ago
|
||
Landed with visual review from dvander:
http://hg.mozilla.org/integration/mozilla-inbound/rev/5c40bfc44022
Target Milestone: --- → mozilla12
Comment 10•14 years ago
|
||
Assignee: general → dmandelin
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
Comment 11•14 years ago
|
||
(In reply to Nicholas Nethercote [:njn] from comment #8)
> (In reply to Julia Lawall from comment #7)
> > There are about 50 empty-bodied ifs in
> > ipc/chromium/src/base/third_party/purify/pure_api.c.
> > These all look intentional.
>
> Yes, but that file is only compiled on Windows so if you turn on
> -Wempty-body for GCC it doesn't matter. I only get two extra warnings when
> I turn it on for Linux64 debug builds, both in gfx/ycbcr/yuv_convert.cpp.
In case this comes up in the future, you can temporarily disable warnings in GCC by wrapping affected code with
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wempty-body"
#pragma GCC diagnostic pop
You need to log in
before you can comment on or make changes to this bug.
Description
•