Closed Bug 747469 Opened 8 years ago Closed 8 years ago

GCC 4.6 warning: nsHTMLDocument.cpp:2308:49: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits]

Categories

(Core :: DOM: Core & HTML, defect)

x86_64
Linux
defect
Not set

Tracking

()

RESOLVED FIXED
mozilla15

People

(Reporter: dholbert, Assigned: dholbert)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

{
content/html/document/src/nsHTMLDocument.cpp: In member function ‘virtual nsresult nsHTMLDocument::ChangeContentEditableCount(nsIContent*, PRInt32)’:
content/html/document/src/nsHTMLDocument.cpp:2308:49: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits]
}

This is from this code...
> 2305 nsHTMLDocument::ChangeContentEditableCount(nsIContent *aElement,
> 2306                                            PRInt32 aChange)
> 2307 {
> 2308   NS_ASSERTION(mContentEditableCount + aChange >= 0,
> 2309                "Trying to decrement too much.");
...added in this cset: http://hg.mozilla.org/mozilla-central/rev/15cda702358e

mContentEditableCount is unsigned, so [mContentEditableCount + aChange] is unsigned and will always be >=0 by definition.  So the assertion doesn't check what it's trying to check.

Simplest/cleanest fix is probably to just add a PRInt32 cast.
Attached patch fix v1Splinter Review
Assignee: nobody → dholbert
Status: NEW → ASSIGNED
Attachment #617040 - Flags: review?(peterv)
Attachment #617040 - Flags: review?(peterv) → review+
https://hg.mozilla.org/mozilla-central/rev/5da92b15cfeb
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.