Fix various compiler warnings
authorSean Cannella <seanc@fb.com>
Thu, 21 Aug 2014 21:26:49 +0000 (14:26 -0700)
committerSara Golemon <sgolemon@fb.com>
Tue, 9 Sep 2014 21:22:23 +0000 (14:22 -0700)
Summary:
This allows projects that use -Wextra (sans -Wunused-parameter) to
compile folly.

Test Plan: compiled with gcc and clang

Reviewed By: meyering@fb.com

Subscribers: njormrod, kmdent, fma, benyluo, shikong, ranjeeth, subodh, pgriess

FB internal diff: D1509827

folly/String-inl.h
folly/detail/ThreadLocalDetail.h

index 65870582e7cf094314a2abe8ddfb34a8537d1484..28aead22360baa8e9b64ccf5218960f1b0f17f8c 100644 (file)
@@ -322,7 +322,7 @@ void internalSplit(DelimT delim, StringPiece sp, OutputIterator out,
 
   int tokenStartPos = 0;
   int tokenSize = 0;
-  for (int i = 0; i <= strSize - dSize; ++i) {
+  for (size_t i = 0; i <= strSize - dSize; ++i) {
     if (atDelim(&s[i], delim)) {
       if (!ignoreEmpty || tokenSize > 0) {
         *out++ = conv(StringPiece(&s[tokenStartPos], tokenSize));
@@ -617,7 +617,7 @@ bool hexlify(const InputString& input, OutputString& output,
   static char hexValues[] = "0123456789abcdef";
   int j = output.size();
   output.resize(2 * input.size() + output.size());
-  for (int i = 0; i < input.size(); ++i) {
+  for (size_t i = 0; i < input.size(); ++i) {
     int ch = input[i];
     output[j++] = hexValues[(ch >> 4) & 0xf];
     output[j++] = hexValues[ch & 0xf];
@@ -639,7 +639,7 @@ bool unhexlify(const InputString& input, OutputString& output) {
            -1;
   };
 
-  for (int i = 0; i < input.size(); i += 2) {
+  for (size_t i = 0; i < input.size(); i += 2) {
     int highBits = unhex(input[i]);
     int lowBits = unhex(input[i + 1]);
     if (highBits < 0 || lowBits < 0) {
index b1a380e7a3fc7347c2063caba90a59665b6710cc..29dda6cee0577e49cf85a1808dba3f092159f9e3 100644 (file)
@@ -428,7 +428,8 @@ struct StaticMeta {
 
 #if !__APPLE__
 template <class Tag>
-FOLLY_TLS ThreadEntry StaticMeta<Tag>::threadEntry_ = {0};
+FOLLY_TLS ThreadEntry StaticMeta<Tag>::threadEntry_{nullptr, 0,
+                                                    nullptr, nullptr};
 #endif
 template <class Tag> StaticMeta<Tag>* StaticMeta<Tag>::inst_ = nullptr;