Closed Bug 743404 Opened 13 years ago Closed 13 years ago

nsHtml5TreeOperation.cpp:276:28: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits]

Categories

(Core :: DOM: HTML Parser, defect)

x86_64
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla14

People

(Reporter: dholbert, Assigned: dholbert)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

g++ 4.6.3 gives me this build warning: { parser/html/nsHtml5TreeOperation.cpp: In member function ‘nsresult nsHtml5TreeOperation::Perform(nsHtml5TreeOpExecutor*, nsIContent**)’: parser/html/nsHtml5TreeOperation.cpp:276:28: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits] } ...for this code: > 275 PRUint32 pos = parent->IndexOf(node); > 276 NS_ASSERTION((pos >= 0), "Element not found as child of its parent"); The assertion there probably wants to compare to nsTArray::NoIndex (which is something like UINT_MAX, IIRC) This code has been basically the same since this file was added in bug 487949, in 2009, but I think GCC only recently started reporting warnings for this issue.
(In reply to Daniel Holbert [:dholbert] from comment #0) > The assertion there probably wants to compare to nsTArray::NoIndex (which is > something like UINT_MAX, IIRC) > > This code has been basically the same since this file was added in bug > 487949, in 2009, but I think GCC only recently started reporting warnings > for this issue. Oh, nevermind -- I was assuming parent was a nsTArray, but it's actually it's a nsIContent*. And I seem to remember nsIContent::IndexOf recently changing to return an unsigned value, so that would make sense as a proximate cause for this warning cropping up.
No longer blocks: html5-parsing-land
er, just kidding -- nsINode::IndexOf returns a _signed_ value and always has, AFAICT: http://hg.mozilla.org/mozilla-central/annotate/a402c2064466/content/base/public/nsINode.h#l439 So the real bug here is that |pos| is a PRUint32 when it should be a PRInt32.
Attached patch fixSplinter Review
Assignee: nobody → dholbert
Status: NEW → ASSIGNED
Attachment #613048 - Flags: review?(hsivonen)
Comment on attachment 613048 [details] [diff] [review] fix Thanks for catching this.
Attachment #613048 - Flags: review?(hsivonen) → review+
No problem -- thanks for the review! Pushed: https://hg.mozilla.org/integration/mozilla-inbound/rev/c5a10dbe276b
Target Milestone: --- → mozilla14
Status: ASSIGNED → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: