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

RESOLVED FIXED in mozilla15

Status

()

Core
DOM
RESOLVED FIXED
5 years ago
5 years ago

People

(Reporter: dholbert, Assigned: dholbert)

Tracking

(Blocks: 2 bugs)

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

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Assignee)

Description

5 years ago
{
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.
(Assignee)

Comment 1

5 years ago
Created attachment 617040 [details] [diff] [review]
fix v1
Assignee: nobody → dholbert
Status: NEW → ASSIGNED
Attachment #617040 - Flags: review?(peterv)
Attachment #617040 - Flags: review?(peterv) → review+
(Assignee)

Comment 2

5 years ago
https://hg.mozilla.org/projects/birch/rev/5da92b15cfeb
Target Milestone: --- → mozilla15
https://hg.mozilla.org/mozilla-central/rev/5da92b15cfeb
Status: ASSIGNED → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → FIXED
(Assignee)

Updated

5 years ago
Blocks: 768344
You need to log in before you can comment on or make changes to this bug.