Note: There are a few cases of duplicates in user autocompletion which are being worked on.

nsGlobalWindow.cpp:8812:93: warning: comparison between signed and unsigned integer expressions

RESOLVED FIXED in mozilla6

Status

()

Core
DOM
RESOLVED FIXED
6 years ago
6 years ago

People

(Reporter: dholbert, Assigned: dholbert)

Tracking

Trunk
mozilla6
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [build_warning])

Attachments

(1 attachment)

(Assignee)

Description

6 years ago
Created attachment 528120 [details] [diff] [review]
fix

nsGlobalWindow.cpp currently has only one GCC warning, introduced a few weeks back in bug 646972:
> nsGlobalWindow.cpp:8812:93: warning: comparison between signed and unsigned integer expressions

Relevant chunk of code:
> 8793 nsGlobalWindow::SetTimeoutOrInterval(nsIScriptTimeoutHandler *aHandler,
> 8794                                      PRInt32 interval,
> 8795                                      PRBool aIsInterval, PRInt32 *aReturn)
> 8796 {
[...]
> 8806   // Disallow negative intervals.  If aIsInterval also disallow 0,
> 8807   // because we use that as a "don't repeat" flag.
> 8808   interval = NS_MAX(aIsInterval ? 1 : 0, interval);
> 8809 
> 8810   // Make sure we don't proceed with an interval larger than our timer
> 8811   // code can handle.
> 8812   if (interval > PR_IntervalToMilliseconds(DOM_MAX_TIMEOUT_VALUE)) {
> 8813     interval = PR_IntervalToMilliseconds(DOM_MAX_TIMEOUT_VALUE);
> 8814   }
http://mxr.mozilla.org/mozilla-central/source/dom/base/nsGlobalWindow.cpp#8793

GCC is warns about the comparison at line 8812 because |interval| is a signed int whereas PR_IntervalToMilliseconds returns an unsigned int.

We've already clamped |interval| to be non-negative (at line 8808) so it's safe to just cast it to an unsigned value.  This patch does that, along with nixing the second call to PR_IntervalToMilliseconds and removing an unnecessary null-check-after-new a few lines later.
Attachment #528120 - Flags: review?(bzbarsky)

Comment 1

6 years ago
Comment on attachment 528120 [details] [diff] [review]
fix

r=me
Attachment #528120 - Flags: review?(bzbarsky) → review+
(Assignee)

Comment 2

6 years ago
http://hg.mozilla.org/mozilla-central/rev/63ef637c94bb
Status: ASSIGNED → RESOLVED
Last Resolved: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla6
You need to log in before you can comment on or make changes to this bug.