Bug 132947 - Build error in Source/WebCore/fileapi/Blob.cpp
Summary: Build error in Source/WebCore/fileapi/Blob.cpp
Status: RESOLVED DUPLICATE of bug 132678
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-05-15 04:27 PDT by Tanay
Modified: 2014-05-15 09:31 PDT (History)
2 users (show)

See Also:


Attachments
Patch (1.40 KB, patch)
2014-05-15 05:15 PDT, Tanay
ap: review-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tanay 2014-05-15 04:27:37 PDT
Revision: 168893
Build command: build-webkit --efl --cmakeargs="-DSHARED_CORE=ON" --cmakeargs="-DENABLE_WEBKIT=OFF" --update-efl

Error Text:

[ 14%] Building CXX object Source/WebCore/CMakeFiles/WebCore.dir/fileapi/Blob.cpp.o
/home/tanay.c/webkit/Source/WebCore/fileapi/Blob.cpp: In member function ‘long long unsigned int WebCore::Blob::size() const’:
/home/tanay.c/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[1]: *** [Source/WebCore/CMakeFiles/WebCore.dir/all] Error 2
make: *** [all] Error 2

Dependencies:
Related to changes as part of http://trac.webkit.org/changeset/168435
Comment 1 Tanay 2014-05-15 05:15:36 PDT
Created attachment 231500 [details]
Patch
Comment 2 Alexey Proskuryakov 2014-05-15 09:29:46 PDT
Comment on attachment 231500 [details]
Patch

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

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

The proposed code is incorrect - an unsigned long long value is always less than or equal to std::numeric_limits<unsigned long long>::max(), so comparing these makes is meaningless. The purpose of this check is to ensure that casting to a signed long long won't change the value.

I think that you need something like:

m_size = (actualSize <= static_cast<unsigned long long>(std::numeric_limits<long long>::max())) ? static_cast<long long>(actualSize) : 0;

Or there may be some other idiom that I'm not aware of. Possibly something in CheckedArithmetic.h?
Comment 3 Alexey Proskuryakov 2014-05-15 09:31:19 PDT

*** This bug has been marked as a duplicate of bug 132678 ***