jsworkers.cpp:170:35: warning: NULL used in arithmetic [-Wpointer-arith]

RESOLVED FIXED in mozilla14

Status

()

Core
JavaScript Engine
RESOLVED FIXED
5 years ago
5 years ago

People

(Reporter: dholbert, Assigned: dholbert)

Tracking

(Blocks: 1 bug)

Trunk
mozilla14
x86_64
Linux
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

Filing bug on this new build warning:
> js/src/shell/jsworkers.cpp: In member function ‘bool js::workers::WorkerParent::addChild(js::workers::Worker*)’:
> js/src/shell/jsworkers.cpp:170:35: warning: NULL used in arithmetic [-Wpointer-arith]

This is from this line:
> 168     bool addChild(Worker *w) {
> 169         AutoLock hold(getLock());
> 170         return children.put(w) != NULL;
> 171     }

HashSet::put used to return a pointer, but now it returns a bool (as of bug 740153), so GCC is warning because we're comparing a bool != NULL.
Created attachment 612259 [details] [diff] [review]
fix v1

This updates the HashSet::put documentation as well, to indicate that it now returns false (not NULL) on failure.
Attachment #612259 - Flags: review?(terrence)
Assignee: general → dholbert
Status: NEW → ASSIGNED
Comment on attachment 612259 [details] [diff] [review]
fix v1

Review of attachment 612259 [details] [diff] [review]:
-----------------------------------------------------------------

Oddly, neither clang++ nor g++-4.6.3 warn for me here.  Thanks for fixing this.

::: js/public/HashTable.h
@@ -1152,5 @@
>      bool has(const Lookup &l) const {
>          return impl.lookup(l) != NULL;
>      }
>  
> -    /* Overwrite existing value with v. Return NULL on oom. */

It looks like I remembered to update the comment correctly on HashSet, but not on HashMap.
Attachment #612259 - Flags: review?(terrence) → review+
Comment on attachment 612259 [details] [diff] [review]
fix v1

(oops... looks like bugzilla autocomplete stuck the " [r=longsonr]" into the patch name.  That wasn't supposed to be there. :))

> Oddly, neither clang++ nor g++-4.6.3 warn for me here.  Thanks for fixing this.

My g++-4.6.3 warned me, but I'm on Ubuntu 12.04 beta2 which and I received a g++ update today, so this might be something that it only recently started detecting.

Thanks for the review!
Attachment #612259 - Attachment description: fix v1 [r=longsonr] → fix v1
(In reply to Daniel Holbert [:dholbert] from comment #3)
> Comment on attachment 612259 [details] [diff] [review]
> fix v1
> 
> (oops... looks like bugzilla autocomplete stuck the " [r=longsonr]" into the
> patch name.  That wasn't supposed to be there. :)

(er, s/bugzilla autocomplete/firefox autocomplete for the patch-name field/
https://hg.mozilla.org/integration/mozilla-inbound/rev/c508a51af843
Target Milestone: --- → mozilla14
https://hg.mozilla.org/mozilla-central/rev/c508a51af843
Status: ASSIGNED → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.