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

RESOLVED FIXED in mozilla14

Status

()

Core
DOM
RESOLVED FIXED
5 years ago
5 years ago

People

(Reporter: dholbert, Assigned: dholbert)

Tracking

(Blocks: 1 bug)

Trunk
mozilla14
x86_64
Linux
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Assignee)

Description

5 years ago
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.
(Assignee)

Comment 1

5 years ago
Created attachment 612373 [details] [diff] [review]
fix
Assignee: nobody → dholbert
Status: NEW → ASSIGNED
Attachment #612373 - Flags: review?(bugs)
(Assignee)

Comment 2

5 years ago
(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))

Updated

5 years ago
Attachment #612373 - Flags: review?(bugs) → review+
(Assignee)

Comment 3

5 years ago
https://hg.mozilla.org/integration/mozilla-inbound/rev/9082d2112975
Target Milestone: --- → mozilla14
https://hg.mozilla.org/mozilla-central/rev/9082d2112975
Status: ASSIGNED → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.