Closed Bug 742438 Opened 8 years ago Closed 8 years ago

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

Categories

(Core :: JavaScript Engine, defect)

x86_64
Linux
defect
Not set

Tracking

()

RESOLVED FIXED
mozilla14

People

(Reporter: dholbert, Assigned: dholbert)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

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.
Attached patch fix v1Splinter Review
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/mozilla-central/rev/c508a51af843
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.