Closed Bug 851556 Opened 7 years ago Closed 7 years ago

GestureEventListener.cpp:140:40: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]

Categories

(Core :: Graphics: Layers, defect)

defect
Not set

Tracking

()

RESOLVED FIXED
mozilla22

People

(Reporter: dholbert, Assigned: dholbert)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

Build warning:
{
/mozilla/gfx/layers/ipc/GestureEventListener.cpp: In member function ‘nsEventStatus mozilla::layers::GestureEventListener::HandleInputEvent(const mozilla::InputData&)’:

/mozilla/gfx/layers/ipc/GestureEventListener.cpp:140:40: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]

/mozilla/gfx/layers/ipc/GestureEventListener.cpp:142:43: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
}

This is from these comparisons:
> 140     if (event.mTime - mTapStartTime <= MAX_TAP_TIME) {
> 141       if (mState == GESTURE_WAITING_DOUBLE_TAP &&
> 142           event.mTime - mLastTapEndTime > MAX_TAP_TIME) {
https://mxr.mozilla.org/mozilla-central/source/gfx/layers/ipc/GestureEventListener.cpp#140

"event.mTime" is a uint32_t, and "mTapStartTime" is a uint64_t -- so the left side of the comparisons ends up having type uint64_t.

MAX_TAP_TIME is an int (i.e. it's signed), for some reason. It's only got one usage outside of the two lines quoted above -- it's passed to PostDelayedTask here:
https://mxr.mozilla.org/mozilla-central/source/gfx/layers/ipc/GestureEventListener.cpp#171
and *there* it's used as an int.  We could easily make it an unsigned value, though, and just let PostDelayedTask implicitly convert it to an int.  (It's not anywhere near UINT32_MAX, so unsigned --> signed conversion will do the right thing.)

SO: I think we should just make MAX_TAP_TIME unsigned, possibly "uint32_t" to match event.mTime, so that the comparisons against it won't trigger build warnings.
Comment on attachment 725458 [details] [diff] [review]
fix v1

Review of attachment 725458 [details] [diff] [review]:
-----------------------------------------------------------------

Cool! Thanks for the fix.
Attachment #725458 - Flags: review?(bugzilla) → review+
https://hg.mozilla.org/mozilla-central/rev/ff9313fd56e4
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla22
You need to log in before you can comment on or make changes to this bug.