Last Comment Bug 744464 - nsPlainTextSerializer.cpp:414:30: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits]
: nsPlainTextSerializer.cpp:414:30: warning: comparison of unsigned expression ...
Status: RESOLVED FIXED
:
Product: Core
Classification: Components
Component: General (show other bugs)
: Trunk
: x86_64 Linux
: -- normal (vote)
: mozilla14
Assigned To: Daniel Holbert [:dholbert]
:
:
Mentors:
Depends on:
Blocks: buildwarning 418727
  Show dependency treegraph
 
Reported: 2012-04-11 10:38 PDT by Daniel Holbert [:dholbert]
Modified: 2012-04-17 18:27 PDT (History)
1 user (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
fix: assert before we decrement (895 bytes, patch)
2012-04-11 10:45 PDT, Daniel Holbert [:dholbert]
bugs: review+
Details | Diff | Splinter Review

Description Daniel Holbert [:dholbert] 2012-04-11 10:38:49 PDT
GCC 4.6.3 build warning:

nsPlainTextSerializer.cpp:414:30: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits]

from this chunk:
> 412   if (id == nsGkAtoms::head) {
> 413     --mHeadLevel;
> 414     NS_ASSERTION(mHeadLevel >= 0, "mHeadLevel < 0");

where mHeadLevel is a PRUint32 (and was when that assertion was added, in bug 418727)

Looks like the purpose here is to be sure we don't decrement a value that is at zero. We should probably be asserting that our value is nonzero before we decrement it.
Comment 1 Daniel Holbert [:dholbert] 2012-04-11 10:39:50 PDT
MXR link to this chunk in the source:
http://mxr.mozilla.org/mozilla-central/source/content/base/src/nsPlainTextSerializer.cpp?mark=414-415#412
Comment 2 Daniel Holbert [:dholbert] 2012-04-11 10:45:01 PDT
Created attachment 614056 [details] [diff] [review]
fix: assert before we decrement
Comment 3 Daniel Holbert [:dholbert] 2012-04-17 09:59:02 PDT
https://hg.mozilla.org/integration/mozilla-inbound/rev/165ec2dea412
Comment 4 Ed Morley [:emorley] 2012-04-17 18:27:55 PDT
https://hg.mozilla.org/mozilla-central/rev/165ec2dea412

Note You need to log in before you can comment on or make changes to this bug.