Commit dfc2add7 authored by Christopher Dykes's avatar Christopher Dykes Committed by Facebook Github Bot

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
parent 79b78eaa
......@@ -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);
......
......@@ -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
......
......@@ -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)) {
......
......@@ -162,8 +162,7 @@ void MemoryIdler::unmapUnusedStack(size_t retain) {
#else
void MemoryIdler::unmapUnusedStack(size_t retain) {
}
void MemoryIdler::unmapUnusedStack(size_t /* retain */) {}
#endif
......
......@@ -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;
}
......
......@@ -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_ << ")";
......
......@@ -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();
}
......
......@@ -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;
}
......
......@@ -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
......
......@@ -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.
......
......@@ -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;
......
......@@ -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); }
}
......
......@@ -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));
......
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