Closed Bug 652559 Opened 14 years ago Closed 14 years ago

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

Categories

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

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla6

People

(Reporter: dholbert, Assigned: dholbert)

References

Details

(Whiteboard: [build_warning])

Attachments

(1 file)

Attached patch fixSplinter Review
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)
Attachment #528120 - Flags: review?(bzbarsky) → review+
Status: ASSIGNED → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla6
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: