Last Comment Bug 742565 - nsRange.cpp:668:47: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
: nsRange.cpp:668:47: warning: comparison between signed and unsigned integer e...
Status: RESOLVED FIXED
:
Product: Core
Classification: Components
Component: DOM (show other bugs)
: Trunk
: x86_64 Linux
: -- normal (vote)
: mozilla14
Assigned To: Daniel Holbert [:dholbert]
:
Mentors:
Depends on:
Blocks: buildwarning 738608
  Show dependency treegraph
 
Reported: 2012-04-04 15:33 PDT by Daniel Holbert [:dholbert]
Modified: 2012-04-10 13:05 PDT (History)
2 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
fix (2.26 KB, patch)
2012-04-04 15:36 PDT, Daniel Holbert [:dholbert]
bugs: review+
Details | Diff | Review

Description Daniel Holbert [:dholbert] 2012-04-04 15:33:05 PDT
Filing bug on these new build warnings:
> content/base/src/nsRange.cpp: In member function ‘virtual nsresult nsRange::ComparePoint(nsIDOMNode*, PRInt32, PRInt16*)’:
> content/base/src/nsRange.cpp:668:47: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
> content/base/src/nsRange.cpp: In member function ‘nsresult nsRange::SetStart(nsINode*, PRInt32)’:
> content/base/src/nsRange.cpp:932:48: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
> content/base/src/nsRange.cpp: In member function ‘nsresult nsRange::SetEnd(nsINode*, PRInt32)’:
> content/base/src/nsRange.cpp:996:48: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]

In each case, it's something like:
> if (aOffset < 0 || aOffset > aParent->Length()) {
...where aOffset is signed and Length() returns an unsigned value.

This comparison would only be problematic if aOffset were negative; however, we're already ensuring it's nonnegative before we perform the comparison.  So we can just cast it to be a signed val for the purpose of the comparison.
Comment 1 Daniel Holbert [:dholbert] 2012-04-04 15:36:25 PDT
Created attachment 612373 [details] [diff] [review]
fix
Comment 2 Daniel Holbert [:dholbert] 2012-04-04 15:37:48 PDT
(In reply to Daniel Holbert [:dholbert] from comment #0)
> So we can just cast it to be a signed val for the purpose of the comparison.

(er I meant "cast it to be an _un_signed val" (which the attached patch does))
Comment 3 Daniel Holbert [:dholbert] 2012-04-10 00:47:17 PDT
https://hg.mozilla.org/integration/mozilla-inbound/rev/9082d2112975
Comment 4 :Ehsan Akhgari (busy, don't ask for review please) 2012-04-10 13:05:10 PDT
https://hg.mozilla.org/mozilla-central/rev/9082d2112975

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