Closed Bug 829369 Opened 12 years ago Closed 12 years ago

nsAnimationManager.cpp:269:80: warning: comparison between signed and unsigned integer expressions

Categories

(Core :: CSS Parsing and Computation, defect)

x86
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla21

People

(Reporter: dholbert, Assigned: dholbert)

References

(Blocks 1 open bug)

Details

Attachments

(1 file, 1 obsolete file)

We can nearly mark layout/style as FAIL_ON_WARNINGS, but there's one remaining warning (on gcc): nsAnimationManager.cpp:269:80: warning: comparison between signed and unsigned integer expressions https://tbpl.mozilla.org/php/getParsedLog.php?id=18681193&tree=Try#error0 Filing this bug on fixing that.
Assignee: nobody → dholbert
Status: NEW → ASSIGNED
Hardware: x86_64 → x86
Attached patch fix v1: cast Length() to ptrdiff_t (obsolete) (deleted) — Splinter Review
The build warning is for the comparison in this ABORT_IF_FALSE: > const AnimationPropertySegment *segment = prop.mSegments.Elements(); [...] > NS_ABORT_IF_FALSE(segment - prop.mSegments.Elements() < > prop.mSegments.Length(), > "ran off end"); So, we're comparing a uint32 to the difference between two pointers. ptrdiff_t is ready-made for this sort of thing. Let's just cast Length() to that.
Attachment #700838 - Flags: review?(dbaron)
Try run that includes this patch (w/ build jobs only, just to verify that it builds everywhere): https://tbpl.mozilla.org/?tree=Try&rev=69a0703b85dc
Depends on: 435442
Actually, I like this version slightly better. This version casts the pointer-difference to a size_t (after ensuring it'll be nonnegative), rather than casting the length to a ptrdiff_t. I like this better because it shouldn't be possible for it to do an invalid cast (whereas the previous version could technically perform an invalid cast, if Length() was larger than INT_MAX and we were on a 32-bit platform.)
Attachment #700838 - Attachment is obsolete: true
Attachment #700838 - Flags: review?(dbaron)
Attachment #700866 - Flags: review?(dbaron)
Comment on attachment 700866 [details] [diff] [review] fix v2: cast pointer-subtraction to a size_t, after ensuring it'll be nonnegative r=dbaron
Attachment #700866 - Flags: review?(dbaron) → review+
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla21
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: