Adjust a few things to avoid triggering warnings under MSVC
authorChristopher Dykes <cdykes@fb.com>
Thu, 16 Feb 2017 21:10:26 +0000 (13:10 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Thu, 16 Feb 2017 21:20:02 +0000 (13:20 -0800)
Summary: This includes both unused parameters (W4100) and conditional expression is constant (W4127).

Reviewed By: yfeldblum

Differential Revision: D4525057

fbshipit-source-id: 7c057dbe239d02fa2e3ce96373d53814591994ec

13 files changed:
folly/FBString.h
folly/MemoryMapping.cpp
folly/SharedMutex.h
folly/detail/MemoryIdler.cpp
folly/detail/SocketFastOpen.cpp
folly/io/async/AsyncSocket.cpp
folly/portability/Builtins.h
folly/portability/PThread.h
folly/portability/Sockets.cpp
folly/portability/SysMman.cpp
folly/portability/SysResource.cpp
folly/portability/SysStat.cpp
folly/portability/Unistd.cpp

index 638ead111315c996f11b4640b1bf7e3c922a7434..703db026e45b7156468138062b86d02fad0d475d 100644 (file)
@@ -137,7 +137,8 @@ inline std::pair<InIt, OutIt> copy_n(
 template <class Pod, class T>
 inline void podFill(Pod* b, Pod* e, T c) {
   FBSTRING_ASSERT(b && e && b <= e);
-  /*static*/ if (sizeof(T) == 1) {
+  constexpr auto kUseMemset = sizeof(T) == 1;
+  /* static */ if (kUseMemset) {
     memset(b, c, size_t(e - b));
   } else {
     auto const ee = b + ((e - b) & ~7u);
index a92e73f8725506f6cf8e90c97ae85b2d6caaeb92..ae4cac71aeaba2487ec745840aa604ea1daf4179 100644 (file)
@@ -94,8 +94,7 @@ void getDeviceOptions(dev_t device, off_t& pageSize, bool& autoExtend) {
   }
 }
 #else
-inline void getDeviceOptions(dev_t device, off_t& pageSize,
-                             bool& autoExtend) { }
+inline void getDeviceOptions(dev_t, off_t&, bool&) {}
 #endif
 
 }  // namespace
index a0f79f5b32ac00e45d0b78a71d8ed9f23a2cb47c..49dd29c64a3c65929e93ea5dad2e4be85cb386e7 100644 (file)
@@ -765,7 +765,7 @@ class SharedMutexImpl {
       }
 
       uint32_t after = (state & kMayDefer) == 0 ? 0 : kPrevDefer;
-      if (!ReaderPriority || (state & (kMayDefer | kHasS)) == 0) {
+      if (!kReaderPriority || (state & (kMayDefer | kHasS)) == 0) {
         // Block readers immediately, either because we are in write
         // priority mode or because we can acquire the lock in one
         // step.  Note that if state has kHasU, then we are doing an
@@ -806,7 +806,7 @@ class SharedMutexImpl {
             return false;
           }
 
-          if (ReaderPriority && (state & kHasE) == 0) {
+          if (kReaderPriority && (state & kHasE) == 0) {
             assert((state & kBegunE) != 0);
             if (!state_.compare_exchange_strong(state,
                                                 (state & ~kBegunE) | kHasE)) {
index 22be85fba22e4312a429cafa1a2ffa5f95fa35f8..12286855cd4b00e3f65891d43e9d4544cb5ffbdc 100644 (file)
@@ -162,8 +162,7 @@ void MemoryIdler::unmapUnusedStack(size_t retain) {
 
 #else
 
-void MemoryIdler::unmapUnusedStack(size_t retain) {
-}
+void MemoryIdler::unmapUnusedStack(size_t /* retain */) {}
 
 #endif
 
index 56fa88d80e72744f99d192e86842e3831e400c53..465a07f9b248744fd3cc89fddfd8020ff7261604 100644 (file)
@@ -107,17 +107,18 @@ bool tfo_succeeded(int sockfd) {
 
 #else
 
-ssize_t tfo_sendmsg(int sockfd, const struct msghdr* msg, int flags) {
+ssize_t
+tfo_sendmsg(int /* sockfd */, const struct msghdr* /* msg */, int /* flags */) {
   errno = EOPNOTSUPP;
   return -1;
 }
 
-int tfo_enable(int sockfd, size_t max_queue_size) {
+int tfo_enable(int /* sockfd */, size_t /* max_queue_size */) {
   errno = ENOPROTOOPT;
   return -1;
 }
 
-bool tfo_succeeded(int sockfd) {
+bool tfo_succeeded(int /* sockfd */) {
   errno = EOPNOTSUPP;
   return false;
 }
index d88f9d851deff798f25930e09ff2d7ecd6a44650..721686c517d20a4ad7b932c4fa672bcfd4285971 100644 (file)
@@ -1277,6 +1277,7 @@ int AsyncSocket::setCongestionFlavor(const std::string &cname) {
 }
 
 int AsyncSocket::setQuickAck(bool quickack) {
+  (void)quickack;
   if (fd_ < 0) {
     VLOG(4) << "AsyncSocket::setQuickAck() called on non-open socket "
                << this << "(state=" << state_ << ")";
index 98bbb0975d19448645d2d3bde20d94b9134d4203..932d9c407b17b572ef8348602ff0e4ae6f77f14c 100755 (executable)
@@ -78,6 +78,7 @@ FOLLY_ALWAYS_INLINE int __builtin_popcountll(unsigned long long x) {
 
 FOLLY_ALWAYS_INLINE void* __builtin_return_address(unsigned int frame) {
   // I really hope frame is zero...
+  (void)frame;
   assert(frame == 0);
   return _ReturnAddress();
 }
index 3d97aae4a5bc5a71efc04697fb5929f85347a07b..2ddf98052f67dc4abde54baf53364590f50a3331 100755 (executable)
@@ -77,7 +77,9 @@ pthread_attr_setstack(pthread_attr_t* attr, void* stackaddr, size_t stacksize) {
   return 0;
 }
 
-inline int pthread_attr_getguardsize(pthread_attr_t* attr, size_t* guardsize) {
+inline int pthread_attr_getguardsize(
+    pthread_attr_t* /* attr */,
+    size_t* guardsize) {
   *guardsize = 0;
   return 0;
 }
index 68f70c860681a8821ea541a32801394a22dd24f6..b5f0b7d517de83ef1e410f13362ecb2fb6111e79 100755 (executable)
@@ -256,7 +256,7 @@ ssize_t recvfrom(
   return recvfrom(s, (void*)buf, (size_t)len, flags, from, fromlen);
 }
 
-ssize_t recvmsg(int s, struct msghdr* message, int fl) {
+ssize_t recvmsg(int s, struct msghdr* message, int /* flags */) {
   SOCKET h = fd_to_socket(s);
 
   // Don't currently support the name translation.
@@ -313,7 +313,7 @@ ssize_t send(int s, const void* buf, int len, int flags) {
   return send(s, (const void*)buf, (size_t)len, flags);
 }
 
-ssize_t sendmsg(int s, const struct msghdr* message, int fl) {
+ssize_t sendmsg(int s, const struct msghdr* message, int /* flags */) {
   SOCKET h = fd_to_socket(s);
 
   // Unfortunately, WSASendMsg requires the socket to have been opened
index 9748f0373eba999d901019f9c5c70874941aa2fd..cc24807340aa7af1cd6fec5ae558d686948d3e50 100755 (executable)
@@ -56,7 +56,7 @@ static size_t alignToAllocationGranularity(size_t s) {
 }
 
 extern "C" {
-int madvise(const void* addr, size_t len, int advise) {
+int madvise(const void* /* addr */, size_t /* len */, int /* advise */) {
   // We do nothing at all.
   // Could probably implement dontneed via VirtualAlloc
   // with the MEM_RESET and MEM_RESET_UNDO flags.
index f4af315e1daec9490964682c417b6bdff01190dd..05dc60f1f072ac0593034813366640b52185fb2f 100755 (executable)
@@ -30,13 +30,13 @@ int getrlimit(int type, rlimit* dst) {
   return -1;
 }
 
-int getrusage(int who, rusage* usage) {
+int getrusage(int /* who */, rusage* usage) {
   // You get NOTHING! Good day to you sir.
   ZeroMemory(usage, sizeof(rusage));
   return 0;
 }
 
-int setrlimit(int type, rlimit* src) {
+int setrlimit(int /* type */, rlimit* /* src */) {
   // Do nothing for setting them for now.
   // We couldn't set the stack size at runtime even if we wanted to.
   return 0;
index eb2b52e5ccefdc1bd53a4d12a0246a93f0121ed3..8efb001bc1185ed1332c46f8fa88db40048ce353 100755 (executable)
@@ -51,7 +51,9 @@ int fchmod(int fd, mode_t mode) {
 // Just return the result of a normal stat for now
 int lstat(const char* path, struct stat* st) { return stat(path, st); }
 
-int mkdir(const char* fn, int mode) { return _mkdir(fn); }
+int mkdir(const char* fn, int /* mode */) {
+  return _mkdir(fn);
+}
 
 int umask(int md) { return _umask(md); }
 }
index 32e01f1f00aef2ae4a5064a7dc1f7cd4212f17ac..4d387b0220a199a6af36475e0f6928bbfc95ea1e 100755 (executable)
@@ -228,7 +228,9 @@ ssize_t readlink(const char* path, char* buf, size_t buflen) {
   return ret;
 }
 
-void* sbrk(intptr_t i) { return (void*)-1; }
+void* sbrk(intptr_t /* i */) {
+  return (void*)-1;
+}
 
 unsigned int sleep(unsigned int seconds) {
   Sleep((DWORD)(seconds * 1000));