Commit cb0687b1 authored by Dave Tapuska's avatar Dave Tapuska Committed by Commit Bot

Revert "Silence 64 to 32 bit truncation errors on WTF strings."

This reverts commit 7223839e.

Reason for revert: Possibly per regression: https://bugs.chromium.org/p/chromium/issues/detail?id=852988

Original change's description:
> Silence 64 to 32 bit truncation errors on WTF strings.
> 
> strlen returns size_t which can be 64 bits yet all of the WTF strings
> use 32 storage lengths. Add a helper function string_unsigned which
> returns the strlen with a SafeCast to unsigned. Place it in an
> implementation file to avoid increase in binary size due to inlining.
> 
> BUG=588506
> 
> Change-Id: I3b5025c1fee9b1eda9cd017af6bdfc66d808e802
> Reviewed-on: https://chromium-review.googlesource.com/1096133
> Reviewed-by: Kentaro Hara <haraken@chromium.org>
> Reviewed-by: Yuta Kitamura <yutak@chromium.org>
> Commit-Queue: Dave Tapuska <dtapuska@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#566415}

TBR=yutak@chromium.org,haraken@chromium.org,dtapuska@chromium.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: 588506
Change-Id: I85d200afa3816ffefdbfa34ad86f8bddc168ccb1
Reviewed-on: https://chromium-review.googlesource.com/1101761Reviewed-by: default avatarDave Tapuska <dtapuska@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarYuta Kitamura <yutak@chromium.org>
Commit-Queue: Dave Tapuska <dtapuska@chromium.org>
Cr-Commit-Position: refs/heads/master@{#567978}
parent 73c5c4e2
......@@ -127,7 +127,6 @@ jumbo_component("wtf") {
"stack_util.h",
"static_constructors.h",
"std_lib_extras.h",
"string_extras.cc",
"string_extras.h",
"string_hasher.h",
"terminated_array.h",
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "third_party/blink/renderer/platform/wtf/string_extras.h"
#include "third_party/blink/renderer/platform/wtf/std_lib_extras.h"
namespace WTF {
unsigned strlen_unsigned(const char* string) {
return SafeCast<unsigned>(strlen(string));
}
} // namespace WTF
......@@ -28,7 +28,6 @@
#include <string.h>
#include "build/build_config.h"
#include "third_party/blink/renderer/platform/wtf/wtf_export.h"
#if defined(OS_POSIX)
#include <strings.h>
......@@ -47,11 +46,4 @@ inline int strcasecmp(const char* s1, const char* s2) {
#endif // defined(COMPILER_MSVC)
namespace WTF {
// Wrapper around strlen with a SafeCast to unsigned from size_t.
WTF_EXPORT unsigned strlen_unsigned(const char* string);
} // namespace WTF
#endif // THIRD_PARTY_BLINK_RENDERER_PLATFORM_WTF_STRING_EXTRAS_H_
......@@ -27,7 +27,6 @@
#include "build/build_config.h"
#include "third_party/blink/renderer/platform/wtf/allocator.h"
#include "third_party/blink/renderer/platform/wtf/hash_table_deleted_value_type.h"
#include "third_party/blink/renderer/platform/wtf/string_extras.h"
#include "third_party/blink/renderer/platform/wtf/text/cstring.h"
#include "third_party/blink/renderer/platform/wtf/text/string_view.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
......@@ -59,9 +58,8 @@ class WTF_EXPORT AtomicString {
AtomicString() = default;
AtomicString(const LChar* chars)
: AtomicString(
chars,
chars ? strlen_unsigned(reinterpret_cast<const char*>(chars)) : 0) {
: AtomicString(chars,
chars ? strlen(reinterpret_cast<const char*>(chars)) : 0) {
}
AtomicString(const char* chars)
: AtomicString(reinterpret_cast<const LChar*>(chars)) {}
......
......@@ -28,7 +28,6 @@
#include <string.h>
#include "third_party/blink/renderer/platform/wtf/allocator.h"
#include "third_party/blink/renderer/platform/wtf/string_extras.h"
#ifndef WTFString_h
#include "third_party/blink/renderer/platform/wtf/text/atomic_string.h"
......@@ -102,7 +101,7 @@ class WTF_EXPORT StringTypeAdapter<char*> {
public:
explicit StringTypeAdapter<char*>(char* buffer)
: buffer_(buffer), length_(strlen_unsigned(buffer)) {}
: buffer_(buffer), length_(strlen(buffer)) {}
unsigned length() const { return length_; }
bool Is8Bit() const { return true; }
......
......@@ -24,7 +24,6 @@
#include "third_party/blink/renderer/platform/wtf/allocator.h"
#include "third_party/blink/renderer/platform/wtf/hash_traits.h"
#include "third_party/blink/renderer/platform/wtf/string_extras.h"
#include "third_party/blink/renderer/platform/wtf/string_hasher.h"
#include "third_party/blink/renderer/platform/wtf/text/atomic_string.h"
......@@ -103,7 +102,7 @@ class CaseFoldingHash {
static inline unsigned GetHash(const char* data) {
return CaseFoldingHash::GetHash(reinterpret_cast<const LChar*>(data),
strlen_unsigned(data));
strlen(data));
}
static inline bool Equal(const StringImpl* a, const StringImpl* b) {
......
......@@ -11,7 +11,6 @@
#include "base/memory/scoped_refptr.h"
#endif
#include <cstring>
#include "third_party/blink/renderer/platform/wtf/string_extras.h"
#include "third_party/blink/renderer/platform/wtf/text/string_impl.h"
#include "third_party/blink/renderer/platform/wtf/text/unicode.h"
......@@ -74,8 +73,7 @@ class WTF_EXPORT StringView {
: StringView(reinterpret_cast<const LChar*>(chars), length) {}
StringView(const LChar* chars)
: StringView(chars,
chars ? strlen_unsigned(reinterpret_cast<const char*>(chars))
: 0) {}
chars ? strlen(reinterpret_cast<const char*>(chars)) : 0) {}
StringView(const char* chars)
: StringView(reinterpret_cast<const LChar*>(chars)) {}
......
......@@ -30,7 +30,6 @@
#include "third_party/blink/renderer/platform/wtf/allocator.h"
#include "third_party/blink/renderer/platform/wtf/compiler.h"
#include "third_party/blink/renderer/platform/wtf/hash_table_deleted_value_type.h"
#include "third_party/blink/renderer/platform/wtf/string_extras.h"
#include "third_party/blink/renderer/platform/wtf/text/ascii_fast_path.h"
#include "third_party/blink/renderer/platform/wtf/text/string_impl.h"
#include "third_party/blink/renderer/platform/wtf/text/string_view.h"
......@@ -93,7 +92,7 @@ class WTF_EXPORT String {
String(const LChar* characters)
: String(reinterpret_cast<const char*>(characters)) {}
String(const char* characters)
: String(characters, characters ? strlen_unsigned(characters) : 0) {}
: String(characters, characters ? strlen(characters) : 0) {}
// Construct a string referencing an existing StringImpl.
String(StringImpl* impl) : impl_(impl) {}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment