RESOLVED FIXED104654
[CoordinatedGraphics] Use unsigned integers for UpdateAtlas IDs
https://bugs.webkit.org/show_bug.cgi?id=104654
Summary [CoordinatedGraphics] Use unsigned integers for UpdateAtlas IDs
Chris Dumez
Reported 2012-12-11 02:57:16 PST
UpdateAtlas currently uses *signed* integer type for its identifier. Due to the way we generate those IDs, it would be safer to use *unsigned* integers. This is because the generated ID will overflow at some point and the C and C++ language standards say that overflow of a signed value is undefined behaviour. In the C99 standard this is in section 6.5. In the C++98 standard it is in section 5 [expr], paragraph 5. "This means that a correct C/C++ program must never generate signed overflow when computing an expression. It also means that a compiler may assume that a program will never generated signed overflow". Note that gcc has -fwrapv flag to assume that signed arithmetic overflow of addition, subtraction and multiplication wraps around using twos-complement representation. However, I still believe it is safer and more consistent to use unsigned integers here.
Attachments
Patch (16.00 KB, patch)
2012-12-11 03:03 PST, Chris Dumez
kenneth: review+
Patch for landing (16.09 KB, patch)
2012-12-11 04:28 PST, Chris Dumez
no flags
Chris Dumez
Comment 1 2012-12-11 03:03:14 PST
Kenneth Rohde Christiansen
Comment 2 2012-12-11 04:04:37 PST
Comment on attachment 178761 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=178761&action=review > Source/WebKit2/ChangeLog:14 > + This patch uses unsigned integer type for UpdateAtlas IDs. does unsigned have defined behavior?
Chris Dumez
Comment 3 2012-12-11 04:15:11 PST
(In reply to comment #2) > (From update of attachment 178761 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=178761&action=review > > > Source/WebKit2/ChangeLog:14 > > + This patch uses unsigned integer type for UpdateAtlas IDs. > > does unsigned have defined behavior? Yes, unsigned integer types are guaranteed to wrap on overflow in C / C++.
Chris Dumez
Comment 4 2012-12-11 04:28:28 PST
Created attachment 178775 [details] Patch for landing Updated the Changelog to clarify the behavior for unsigned integers on overflow.
WebKit Review Bot
Comment 5 2012-12-11 04:54:55 PST
Comment on attachment 178775 [details] Patch for landing Clearing flags on attachment: 178775 Committed r137293: <http://trac.webkit.org/changeset/137293>
WebKit Review Bot
Comment 6 2012-12-11 04:55:00 PST
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.