From c5bae26a33f2082092334d12f6e5f17f683d451b Mon Sep 17 00:00:00 2001 From: Chris Peterson Date: Mon, 17 Mar 2014 22:28:03 -0700 Subject: [PATCH] Bug 984080 - Fix clang and gcc warnings in ipc/chromium/. r=bsmedberg --- ipc/chromium/src/base/shared_memory_posix.cc | 6 ---- ipc/chromium/src/base/string_util.cc | 34 +++++++++++-------- .../src/base/sys_string_conversions_mac.mm | 3 +- 3 files changed, 20 insertions(+), 23 deletions(-) diff --git a/ipc/chromium/src/base/shared_memory_posix.cc b/ipc/chromium/src/base/shared_memory_posix.cc index 57a299c720f7..db1c713850e4 100644 --- a/ipc/chromium/src/base/shared_memory_posix.cc +++ b/ipc/chromium/src/base/shared_memory_posix.cc @@ -17,12 +17,6 @@ namespace base { -namespace { -// Paranoia. Semaphores and shared memory segments should live in different -// namespaces, but who knows what's out there. -const char kSemaphoreSuffix[] = "-sem"; -} - SharedMemory::SharedMemory() : mapped_file_(-1), inode_(0), diff --git a/ipc/chromium/src/base/string_util.cc b/ipc/chromium/src/base/string_util.cc index 72011b319258..21c1a8d5e833 100644 --- a/ipc/chromium/src/base/string_util.cc +++ b/ipc/chromium/src/base/string_util.cc @@ -302,20 +302,6 @@ TrimPositions TrimStringT(const STR& input, ((last_good_char == last_char) ? TRIM_NONE : TRIM_TRAILING)); } -// Removes characters in trim_chars from the beginning and end of input. -// NOTE: Safe to use the same variable for both input and output. -static bool TrimString(const std::wstring& input, - const wchar_t trim_chars[], - std::wstring* output) { - return TrimStringT(input, trim_chars, TRIM_ALL, output) != TRIM_NONE; -} - -static bool TrimString(const std::string& input, - const char trim_chars[], - std::string* output) { - return TrimStringT(input, trim_chars, TRIM_ALL, output) != TRIM_NONE; -} - TrimPositions TrimWhitespace(const std::wstring& input, TrimPositions positions, std::wstring* output) { @@ -501,6 +487,24 @@ struct IntToStringT { } }; + // This set of templates is very similar to the above templates, but + // for testing whether an integer is negative. + template + struct TestNegT {}; + template + struct TestNegT { + static bool TestNeg(INT2 value) { + // value is unsigned, and can never be negative. + return false; + } + }; + template + struct TestNegT { + static bool TestNeg(INT2 value) { + return value < 0; + } + }; + static STR IntToString(INT value) { // log10(2) ~= 0.3 bytes needed per bit or per byte log10(2**8) ~= 2.4. // So round up to allocate 3 output characters per byte, plus 1 for '-'. @@ -510,7 +514,7 @@ struct IntToStringT { // then return the substr of what we ended up using. STR outbuf(kOutputBufSize, 0); - bool is_neg = value < 0; + bool is_neg = TestNegT::TestNeg(value); // Even though is_neg will never be true when INT is parameterized as // unsigned, even the presence of the unary operation causes a warning. UINT res = ToUnsignedT::ToUnsigned(value); diff --git a/ipc/chromium/src/base/sys_string_conversions_mac.mm b/ipc/chromium/src/base/sys_string_conversions_mac.mm index e05ac0f03816..cc5f58b704a5 100644 --- a/ipc/chromium/src/base/sys_string_conversions_mac.mm +++ b/ipc/chromium/src/base/sys_string_conversions_mac.mm @@ -113,11 +113,10 @@ static CFStringRef STLStringToCFStringWithEncodingsT( // Specify the byte ordering explicitly, otherwise CFString will be confused // when strings don't carry BOMs, as they typically won't. static const CFStringEncoding kNarrowStringEncoding = kCFStringEncodingUTF8; + #ifdef __BIG_ENDIAN__ -static const CFStringEncoding kMediumStringEncoding = kCFStringEncodingUTF16BE; static const CFStringEncoding kWideStringEncoding = kCFStringEncodingUTF32BE; #elif defined(__LITTLE_ENDIAN__) -static const CFStringEncoding kMediumStringEncoding = kCFStringEncodingUTF16LE; static const CFStringEncoding kWideStringEncoding = kCFStringEncodingUTF32LE; #endif // __LITTLE_ENDIAN__