[webkit-reviews] review requested: [Bug 107093] WTF should build with -Wshorten-64-to-32 : [Attachment 183118] Patch

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed Jan 16 21:59:58 PST 2013


David Kilzer (:ddkilzer) <ddkilzer at webkit.org> has asked  for review:
Bug 107093: WTF should build with -Wshorten-64-to-32
https://bugs.webkit.org/show_bug.cgi?id=107093

Attachment 183118: Patch
https://bugs.webkit.org/attachment.cgi?id=183118&action=review

------- Additional Comments from David Kilzer (:ddkilzer) <ddkilzer at webkit.org>
<http://webkit.org/b/000000>
<rdar://problem/12551754>

Reviewed by NOBODY (OOPS!).

Source/JavaScriptCore:

* runtime/JSDateMath.cpp:
(JSC::parseDateFromNullTerminatedCharacters): Change 'offset'
from int to long to match change to function in WTF.  Also
remove now unneeded static_cast<int>().

Source/WTF:

* Configurations/Base.xcconfig:
- Enable -Wshorten-64-to-32 by setting
GCC_WARN_64_TO_32_BIT_CONVERSION to YES.

* wtf/Assertions.cpp:
(vprintf_stderr_common):
- Use CFIndex type instead of int for the return value of
CFStringGetMaximumSizeForEncoding().

* wtf/CryptographicallyRandomNumber.cpp:
(ARC4RandomNumberGenerator::stir):
- Use static_cast<int>() since the value is being used to
generate a hash.

* wtf/DateMath.cpp:
(WTF::isLeapYear):
(WTF::ymdhmsToSeconds):
(WTF::parseDateFromNullTerminatedCharacters):
(WTF::parseDateFromNullTerminatedCharacters):
* wtf/DateMath.h:
(WTF::parseDateFromNullTerminatedCharacters):
(WTF::isLeapYear):
- Change types from int to long since most local variables for
'year', 'month', 'day', 'hour' and 'minute' are already type
long.
- Also changed 'offset' variable from int to long, which made it
possible to remove a static_cast<int>().

* wtf/DecimalNumber.cpp:
(WTF::DecimalNumber::toStringDecimal):
(WTF::DecimalNumber::toStringExponential):
- Add overflow checks and static_cast<unsigned>() as needed.

* wtf/FastMalloc.cpp:
(fastMallocStatistics): Change length from int to size_t.
(PageMapFreeObjectFinder::visit): Add ASSERT and
static_cast<int>().
(PageMapMemoryUsageRecorder::recordPendingRegions): Add ASSERT
and static_cast<unsigned>().
(PageMapMemoryUsageRecorder::visit): Add ASSERT and
static_cast<int>() three times.
(AdminRegionRecorder::recordPendingRegions): Add ASSERT and
static_cast<unsigned>().
- NOTE: These ASSERT macros won't be compiled by default on
Debug builds because FastMalloc is disabled in favor of
system malloc.

* wtf/GregorianDateTime.cpp:
(WTF::GregorianDateTime::setToCurrentLocalTime):
- Add static_cast<int>() to convert tm.tm_gmtoff.

* wtf/MD5.cpp:
(WTF::MD5::addBytes):
- Add overflow check with CRASH() for 'length'.  Replace
'length' with local variable, 'len', that is static_cast to
unsigned.

* wtf/dtoa.cpp:
(WTF::multadd): Change int to size_t since these variables are
only used for iterating.
(WTF::mult): Add static_cast<int>() to BigInt::size() results.
(WTF::lshift): Ditto.
(WTF::cmp): Ditto.
(WTF::diff): Ditto.
(WTF::d2b): Ditto.
(WTF::dtoa): Add ASSERT.  Add static_cast<int32_t>().
(WTF::dtoa): Add overflow check with CRASH() and
static_cast<int>().

* wtf/text/ASCIIFastPath.h:
(WTF::copyLCharsFromUCharSource): Change local variables from
unsigned to size_t.

* wtf/text/AtomicString.h:
(WTF::AtomicString::find): Change 'start' arguments from size_t
to unsigned.
(WTF::operator==): Add overflow check with CRASH() and
static_cast<unsigned>().

* wtf/text/Base64.cpp:
(WTF::base64Encode): Add overflow check with CRASH() and
static_cast<unsigned>().
(WTF::base64Decode): Extract in.size() into local variable.
Change UINT_MAX to std::numeric_limits<unsigned>::max().  Add
static_cast<unsigned>().
* wtf/text/Base64.h:
(WTF::base64Encode): Add overflow check with CRASH() and
static_cast<unsigned>() to all four variants.

* wtf/text/StringBuilder.h:
(WTF::StringBuilder::append): Add overflow check with CRASH()
and static_cast<unsigned>().

* wtf/text/StringConcatenate.h:
(StringTypeAdapter<>): Add overflow check with CRASH() and
static_cast<unsigned>() when setting m_length.	One variant
already had an overflow check.

* wtf/text/StringImpl.cpp:
(WTF::StringImpl::createFromLiteral): Add overflow check with
CRASH() and static_cast<unsigned>().
(WTF::StringImpl::create): Add static_cast<unsigned>() since
the overflow check already exists.
(WTF::StringImpl::getData16SlowCase): Change local 'offset'
variable from unsigned to size_t.
(WTF::StringImpl::removeCharacters): Add static_cast<unsigned>()
since we're removing characters and assume the current object
has already been bounds-checked.
(WTF::StringImpl::find): Add static_cast<unsigned>() since an
overflow check already exists.
(WTF::StringImpl::findIgnoringCase): Ditto.
(WTF::StringImpl::replace): Ditto.

* wtf/text/StringImpl.h:
(WTF::StringImpl::StringImpl): Add static_cast<unsigned>() since
the value is being used to compute a hash.

* wtf/text/WTFString.cpp:
(WTF::String::String): Add static_cast<unsigned>() since the
overflow check already exists.
(WTF::String::split): Add static_cast<unsigned>() since the
current object has already been bounds-checked.
(WTF::String::make8BitFrom16BitSource): Add overflow check with
CRASH() and static_cast<unsigned>().
(WTF::String::make16BitFrom8BitSource): Ditto.
(WTF::String::fromUTF8): Add static_cast<unsigned>() since the
overflow check already exists.	Change 'utf16Length' from unsigned
to size_t.  Static cast for 'utf16Length' is checked by ASSERT.
(WTF::String::fromUTF8WithLatin1Fallback): Add overflow check with
CRASH() and static_cast<unsigned>().
(WTF::lengthOfCharactersAsInteger): Ditto.

* wtf/unicode/icu/CollatorICU.cpp:
(WTF::Collator::collate): Add overflow checks with CRASH() and
static_cast<unsigned>() for 'lhsLength' and 'rhsLength'.
---
 23 files changed, 360 insertions(+), 109 deletions(-)


More information about the webkit-reviews mailing list