Bug 107227

Summary: Fix WTF::copyLCharsFromUCharSource() to compile with -Wshorten-64-to-32
Product: WebKit Reporter: David Kilzer (:ddkilzer) <ddkilzer>
Component: Web Template FrameworkAssignee: David Kilzer (:ddkilzer) <ddkilzer>
Status: RESOLVED FIXED    
Severity: Normal CC: benjamin, ojan.autocc, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 107093    
Attachments:
Description Flags
Patch
none
Patch v2 benjamin: review+

David Kilzer (:ddkilzer)
Reported 2013-01-17 22:14:15 PST
<http://webkit.org/b/000000> Reviewed by NOBODY (OOPS!). Fixes the following build error: ASCIIFastPath.h:117:59: error: implicit conversion loses integer precision: 'unsigned long' to 'const unsigned int' [-Werror,-Wshorten-64-to-32] const unsigned endLength = length - ucharsPerLoop + 1; ~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~^~~ 1 error generated. * wtf/text/ASCIIFastPath.h: (WTF::copyLCharsFromUCharSource): Change local variables from unsigned to size_t. --- 2 files changed, 20 insertions(+), 2 deletions(-)
Attachments
Patch (2.00 KB, patch)
2013-01-17 22:14 PST, David Kilzer (:ddkilzer)
no flags
Patch v2 (2.02 KB, patch)
2013-01-17 22:25 PST, David Kilzer (:ddkilzer)
benjamin: review+
David Kilzer (:ddkilzer)
Comment 1 2013-01-17 22:14:16 PST
David Kilzer (:ddkilzer)
Comment 2 2013-01-17 22:22:06 PST
Comment on attachment 183374 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=183374&action=review > Source/WTF/ChangeLog:4 > + Fix WTF::copyLCharsFromUCharSource() to compile with -Wshorten-64-to-32 > + <107227> Oops! Trying to make webkit-patch replace bug ID placeholders in my patches. My re.sub() fu is weak!
David Kilzer (:ddkilzer)
Comment 3 2013-01-17 22:25:18 PST
Created attachment 183376 [details] Patch v2
Benjamin Poulain
Comment 4 2013-01-17 22:30:14 PST
Comment on attachment 183376 [details] Patch v2 View in context: https://bugs.webkit.org/attachment.cgi?id=183376&action=review > Source/WTF/wtf/text/ASCIIFastPath.h:115 > const uintptr_t sourceLoadSize = 32; // Process 32 bytes (16 UChars) each iteration > - const unsigned ucharsPerLoop = sourceLoadSize / sizeof(UChar); > + const size_t ucharsPerLoop = sourceLoadSize / sizeof(UChar); You may want to change sourceLoadSize to size_t for the case where sizeof(size_t) < sizeof(void*)
David Kilzer (:ddkilzer)
Comment 5 2013-01-17 22:38:09 PST
(In reply to comment #4) > (From update of attachment 183376 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=183376&action=review > > > Source/WTF/wtf/text/ASCIIFastPath.h:115 > > const uintptr_t sourceLoadSize = 32; // Process 32 bytes (16 UChars) each iteration > > - const unsigned ucharsPerLoop = sourceLoadSize / sizeof(UChar); > > + const size_t ucharsPerLoop = sourceLoadSize / sizeof(UChar); > > You may want to change sourceLoadSize to size_t for the case where sizeof(size_t) < sizeof(void*) On what systems would the size of size_t be smaller than the size of a pointer? I can't think of any off the top of my head, but it's late and I haven't worked with any "interesting" systems recently. :) This code is also inside this macro: #if OS(DARWIN) && (CPU(X86) || CPU(X86_64)) So I doubt uintptr_t and size_t are going to change sizes in those configurations. Looking at the code, though, I guess it would be a good idea to use size_t just to match the other local variables. Any reason why uintptr_t was chosen here to begin with?
Benjamin Poulain
Comment 6 2013-01-17 22:58:38 PST
> On what systems would the size of size_t be smaller than the size of a pointer? I can't think of any off the top of my head, but it's late and I haven't worked with any "interesting" systems recently. :) I can just be wrong, but I am thinking about mixed ABI like x32. Although, I guess it is the other way around then and sizeof(size_t) > sizeof(void*). > This code is also inside this macro: > > #if OS(DARWIN) && (CPU(X86) || CPU(X86_64)) > > So I doubt uintptr_t and size_t are going to change sizes in those configurations. Right! I missed that. Yep, that does not matter in this case. > Looking at the code, though, I guess it would be a good idea to use size_t just to match the other local variables. Any reason why uintptr_t was chosen here to begin with? I think it was just to have a type semantically correct to explain the "/ size(...)" later.
David Kilzer (:ddkilzer)
Comment 7 2013-01-18 08:14:27 PST
(In reply to comment #6) > > Looking at the code, though, I guess it would be a good idea to use size_t just to match the other local variables. Any reason why uintptr_t was chosen here to begin with? > > I think it was just to have a type semantically correct to explain the "/ size(...)" later. On second thought, I think I'll leave it unchanged for now. It can always be fixed later if it's an issue. Thanks!
David Kilzer (:ddkilzer)
Comment 8 2013-01-18 09:27:33 PST
Darin Adler
Comment 9 2013-01-18 15:49:36 PST
Comment on attachment 183376 [details] Patch v2 View in context: https://bugs.webkit.org/attachment.cgi?id=183376&action=review >>> Source/WTF/wtf/text/ASCIIFastPath.h:115 >>> + const size_t ucharsPerLoop = sourceLoadSize / sizeof(UChar); >> >> You may want to change sourceLoadSize to size_t for the case where sizeof(size_t) < sizeof(void*) > > On what systems would the size of size_t be smaller than the size of a pointer? I can't think of any off the top of my head, but it's late and I haven't worked with any "interesting" systems recently. :) > > This code is also inside this macro: > > #if OS(DARWIN) && (CPU(X86) || CPU(X86_64)) > > So I doubt uintptr_t and size_t are going to change sizes in those configurations. > > Looking at the code, though, I guess it would be a good idea to use size_t just to match the other local variables. Any reason why uintptr_t was chosen here to begin with? Agreed that it should be size_t just for consistency. But not sure that it earns its keep as a named variable, really, since it’s just used in the line below. I think that comment would be clearer if it was on a line by itself and the “32” could just be in the line below; the comment is a great one for the ucharsPerLoop initialization.
Note You need to log in before you can comment on or make changes to this bug.