Closed Bug 513807 Opened 11 years ago Closed 11 years ago

comparison of unsigned expression >= 0 is always true when constructing nsGenConNodes

Categories

(Core :: CSS Parsing and Computation, defect)

x86
Linux
defect
Not set

Tracking

()

RESOLVED FIXED
mozilla1.9.3a1

People

(Reporter: karlt, Assigned: karlt)

References

Details

Attachments

(1 file)

Attached patch patchSplinter Review
gcc's -Wtype-limits warnings (which are not default enabled for C++ code)
noticed:

/home/karl/moz/dev/content/xul/document/src/../../../../layout/base/nsCounterManager.h: In constructor 'nsCounterUseNode::nsCounterUseNode(nsCSSValue::Array*, PRUint32, PRBool)':
/home/karl/moz/dev/content/xul/document/src/../../../../layout/base/nsCounterManager.h:124: warning: comparison of unsigned expression >= 0 is always true

http://hg.mozilla.org/mozilla-central/annotate/f2ebd467b1cd/layout/base/nsCounterManager.h#l124

/home/karl/moz/dev/layout/base/nsQuoteList.h: In constructor 'nsQuoteNode::nsQuoteNode(nsStyleContentType&, PRUint32)':
/home/karl/moz/dev/layout/base/nsQuoteList.h:62: warning: comparison of unsigned expression >= 0 is always true

http://hg.mozilla.org/mozilla-central/annotate/f2ebd467b1cd/layout/base/nsQuoteList.h#l62

The nsGenConNode and nsCounterNode constructors expect PRInt32 arguments but
the assertions are not testing that these are within range.
Attachment #397744 - Flags: review?(dbaron)
Comment on attachment 397744 [details] [diff] [review]
patch

r=dbaron

Should we consider turning these warnings on in configure.in?
Attachment #397744 - Flags: review?(dbaron) → review+
Depends on: 514107
I pushed a slightly different assertion because conversion to PRInt32 is implementation-defined when the value is greater than PR_INT32_MAX.

4.7/3 "If the destination type is signed, the value is unchanged if it can be
       represented in the destination type (and bit-field width); otherwise,
       the value is implementation-defined."

-        NS_ASSERTION(PRInt32(aContentIndex) >= 0, "out of range");
+        NS_ASSERTION(aContentIndex <= PR_INT32_MAX, "out of range");

http://hg.mozilla.org/mozilla-central/rev/19b213c1cc31
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla1.9.3a1
You need to log in before you can comment on or make changes to this bug.