Bug 132678 - Blob.cpp fails to build with some gcc versions because of signed/unsigned comparison
Summary: Blob.cpp fails to build with some gcc versions because of signed/unsigned com...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit EFL (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
: 132947 (view as bug list)
Depends on:
Blocks:
 
Reported: 2014-05-08 02:30 PDT by Praveen Jadhav
Modified: 2014-05-26 00:15 PDT (History)
5 users (show)

See Also:


Attachments
Patch (1.54 KB, patch)
2014-05-08 02:38 PDT, Praveen Jadhav
ap: review-
ap: commit-queue-
Details | Formatted Diff | Diff
Patch (1.47 KB, patch)
2014-05-15 23:39 PDT, Tanay
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Praveen Jadhav 2014-05-08 02:30:04 PDT
WebKit build fails for EFL port with below error

/home/praveen.j/WebKit/Source/WebCore/fileapi/Blob.cpp: In member function ‘long long unsigned int WebCore::Blob::size() const’:
/home/praveen.j/WebKit/Source/WebCore/fileapi/Blob.cpp:127:69: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
cc1plus: all warnings being treated as errors
make[2]: *** [Source/WebCore/CMakeFiles/WebCore.dir/fileapi/Blob.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [Source/WebCore/CMakeFiles/WebCore.dir/all] Error 2
make: *** [all] Error 2
Comment 1 Praveen Jadhav 2014-05-08 02:38:16 PDT
Created attachment 231056 [details]
Patch
Comment 2 Alexey Proskuryakov 2014-05-08 09:30:20 PDT
Comment on attachment 231056 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=231056&action=review

Sorry for the breakage - efl-wk2 bot was green, and efl one does not work.

> Source/WebCore/fileapi/Blob.cpp:127
> -        m_size = (actualSize <= std::numeric_limits<long long>::max()) ? static_cast<long long>(actualSize) : 0;
> +        m_size = (actualSize <= std::numeric_limits<unsigned long long>::max()) ? static_cast<long long>(actualSize) : 0;

The purpose of this check is to verify that the number fits into long long - we already know that it fits into an unsigned long long!

if it complains about signed/unsigned comparison, you probably need something like

actualSize <= static_cast<unsigned long long>(std::numeric_limits<long long>::max()))
Comment 3 Praveen Jadhav 2014-05-09 03:52:44 PDT
Well, its strange that no one else got this error(efl buildbot is successful). I am not sure if this is because of some mismatch in my PC. Will try to resolve this locally.

Thanks!
Comment 4 Alexey Proskuryakov 2014-05-15 09:31:19 PDT
*** Bug 132947 has been marked as a duplicate of this bug. ***
Comment 5 Alexey Proskuryakov 2014-05-15 09:33:19 PDT
As mentioned in duplicate, perhaps we have an existing less wordy solution for this? Perhaps something in CheckedArithmetic.h?
Comment 6 Alexey Proskuryakov 2014-05-15 09:51:20 PDT
Seems like isInBounds<long long>(actualSize) should do the trick.
Comment 7 Tanay 2014-05-15 23:39:07 PDT
Created attachment 231560 [details]
Patch
Comment 8 Tanay 2014-05-15 23:41:10 PDT
(In reply to comment #6)
> Seems like isInBounds<long long>(actualSize) should do the trick.

Yes it fixes the build issue. Uploaded a patch with changes.
Comment 9 Alexey Proskuryakov 2014-05-16 09:33:06 PDT
Comment on attachment 231560 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=231560&action=review

> Source/WebCore/fileapi/Blob.cpp:127
> +        m_size = (WTF::isInBounds<long long>(actualSize)) ? static_cast<long long>(actualSize) : 0;

Does it compile without "WTF::"? Please remove the prefix when landing if it does.
Comment 10 Tanay 2014-05-18 19:51:29 PDT
(In reply to comment #9)
> (From update of attachment 231560 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=231560&action=review
> 
> > Source/WebCore/fileapi/Blob.cpp:127
> > +        m_size = (WTF::isInBounds<long long>(actualSize)) ? static_cast<long long>(actualSize) : 0;
> 
> Does it compile without "WTF::"? Please remove the prefix when landing if it does.

Without 'WTF::' compiler is not able to resolve the function. We should retain it.
Comment 11 WebKit Commit Bot 2014-05-26 00:15:40 PDT
Comment on attachment 231560 [details]
Patch

Clearing flags on attachment: 231560

Committed r169329: <http://trac.webkit.org/changeset/169329>
Comment 12 WebKit Commit Bot 2014-05-26 00:15:46 PDT
All reviewed patches have been landed.  Closing bug.