Fix "warning: comparison between signed and unsigned integer expressions" in nsDOMWindowUtils.cpp

RESOLVED WORKSFORME

Status

()

RESOLVED WORKSFORME
9 years ago
8 years ago

People

(Reporter: dholbert, Assigned: dholbert)

Tracking

Trunk
x86
Linux
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [build_warning])

Attachments

(1 attachment)

(Assignee)

Description

9 years ago
Created attachment 389197 [details] [diff] [review]
fix

When compiling nsDOMWindowUtils.cpp (in mozilla-central), I get these warnings:

/mozilla/dom/base/nsDOMWindowUtils.cpp: In member function ‘virtual nsresult nsDOMWindowUtils::CompareCanvases(nsIDOMHTMLCanvasElement*, nsIDOMHTMLCanvasElement*, PRUint32*, PRUint32*)’:
/mozilla/dom/base/nsDOMWindowUtils.cpp:662: warning: comparison between signed and unsigned integer expressions
/mozilla/dom/base/nsDOMWindowUtils.cpp:663: warning: comparison between signed and unsigned integer expressions
/mozilla/dom/base/nsDOMWindowUtils.cpp:664: warning: comparison between signed and unsigned integer expressions
/mozilla/dom/base/nsDOMWindowUtils.cpp:665: warning: comparison between signed and unsigned integer expressions

The warnings happen because "abs()" returns a *signed* integer, and we implicitly compare its result to an *unsigned* integer using PR_MAX.

Trivial fix: Just cast the result of abs() to be unsigned.  It's guaranteed to be non-negative anyway, since it's an absolute value. :)
Attachment #389197 - Flags: review?(vladimir)
(Assignee)

Updated

9 years ago
Assignee: nobody → dholbert
Status: NEW → ASSIGNED
(Assignee)

Comment 1

8 years ago
This was fixed a while back, as part of bug 530300.  Resolving as WORKSFORME & adding dependency.
Status: ASSIGNED → RESOLVED
Last Resolved: 8 years ago
Depends on: 530300
Resolution: --- → WORKSFORME
Whiteboard: [build_warning]
(Assignee)

Updated

8 years ago
Attachment #389197 - Flags: review?(vladimir)
You need to log in before you can comment on or make changes to this bug.