From dfc2add75af7fa3e32da8566fdb0eeca25366c79 Mon Sep 17 00:00:00 2001 From: Christopher Dykes Date: Thu, 16 Feb 2017 13:10:26 -0800 Subject: [PATCH] Adjust a few things to avoid triggering warnings under MSVC Summary: This includes both unused parameters (W4100) and conditional expression is constant (W4127). Reviewed By: yfeldblum Differential Revision: D4525057 fbshipit-source-id: 7c057dbe239d02fa2e3ce96373d53814591994ec --- folly/FBString.h | 3 ++- folly/MemoryMapping.cpp | 3 +-- folly/SharedMutex.h | 4 ++-- folly/detail/MemoryIdler.cpp | 3 +-- folly/detail/SocketFastOpen.cpp | 7 ++++--- folly/io/async/AsyncSocket.cpp | 1 + folly/portability/Builtins.h | 1 + folly/portability/PThread.h | 4 +++- folly/portability/Sockets.cpp | 4 ++-- folly/portability/SysMman.cpp | 2 +- folly/portability/SysResource.cpp | 4 ++-- folly/portability/SysStat.cpp | 4 +++- folly/portability/Unistd.cpp | 4 +++- 13 files changed, 26 insertions(+), 18 deletions(-) diff --git a/folly/FBString.h b/folly/FBString.h index 638ead11..703db026 100644 --- a/folly/FBString.h +++ b/folly/FBString.h @@ -137,7 +137,8 @@ inline std::pair copy_n( template 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); diff --git a/folly/MemoryMapping.cpp b/folly/MemoryMapping.cpp index a92e73f8..ae4cac71 100644 --- a/folly/MemoryMapping.cpp +++ b/folly/MemoryMapping.cpp @@ -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 diff --git a/folly/SharedMutex.h b/folly/SharedMutex.h index a0f79f5b..49dd29c6 100644 --- a/folly/SharedMutex.h +++ b/folly/SharedMutex.h @@ -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)) { diff --git a/folly/detail/MemoryIdler.cpp b/folly/detail/MemoryIdler.cpp index 22be85fb..12286855 100644 --- a/folly/detail/MemoryIdler.cpp +++ b/folly/detail/MemoryIdler.cpp @@ -162,8 +162,7 @@ void MemoryIdler::unmapUnusedStack(size_t retain) { #else -void MemoryIdler::unmapUnusedStack(size_t retain) { -} +void MemoryIdler::unmapUnusedStack(size_t /* retain */) {} #endif diff --git a/folly/detail/SocketFastOpen.cpp b/folly/detail/SocketFastOpen.cpp index 56fa88d8..465a07f9 100644 --- a/folly/detail/SocketFastOpen.cpp +++ b/folly/detail/SocketFastOpen.cpp @@ -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; } diff --git a/folly/io/async/AsyncSocket.cpp b/folly/io/async/AsyncSocket.cpp index d88f9d85..721686c5 100644 --- a/folly/io/async/AsyncSocket.cpp +++ b/folly/io/async/AsyncSocket.cpp @@ -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_ << ")"; diff --git a/folly/portability/Builtins.h b/folly/portability/Builtins.h index 98bbb097..932d9c40 100755 --- a/folly/portability/Builtins.h +++ b/folly/portability/Builtins.h @@ -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(); } diff --git a/folly/portability/PThread.h b/folly/portability/PThread.h index 3d97aae4..2ddf9805 100755 --- a/folly/portability/PThread.h +++ b/folly/portability/PThread.h @@ -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; } diff --git a/folly/portability/Sockets.cpp b/folly/portability/Sockets.cpp index 68f70c86..b5f0b7d5 100755 --- a/folly/portability/Sockets.cpp +++ b/folly/portability/Sockets.cpp @@ -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 diff --git a/folly/portability/SysMman.cpp b/folly/portability/SysMman.cpp index 9748f037..cc248073 100755 --- a/folly/portability/SysMman.cpp +++ b/folly/portability/SysMman.cpp @@ -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. diff --git a/folly/portability/SysResource.cpp b/folly/portability/SysResource.cpp index f4af315e..05dc60f1 100755 --- a/folly/portability/SysResource.cpp +++ b/folly/portability/SysResource.cpp @@ -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; diff --git a/folly/portability/SysStat.cpp b/folly/portability/SysStat.cpp index eb2b52e5..8efb001b 100755 --- a/folly/portability/SysStat.cpp +++ b/folly/portability/SysStat.cpp @@ -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); } } diff --git a/folly/portability/Unistd.cpp b/folly/portability/Unistd.cpp index 32e01f1f..4d387b02 100755 --- a/folly/portability/Unistd.cpp +++ b/folly/portability/Unistd.cpp @@ -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)); -- 2.34.1