Closed Bug 742565 Opened 8 years ago Closed 8 years ago

nsRange.cpp:668:47: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]

Categories

(Core :: DOM: Core & HTML, defect)

x86_64
Linux
defect
Not set

Tracking

()

RESOLVED FIXED
mozilla14

People

(Reporter: dholbert, Assigned: dholbert)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

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.
Attached patch fixSplinter Review
Assignee: nobody → dholbert
Status: NEW → ASSIGNED
Attachment #612373 - Flags: review?(bugs)
(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))
Attachment #612373 - Flags: review?(bugs) → review+
https://hg.mozilla.org/mozilla-central/rev/9082d2112975
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.