Skip to content

Commit

Permalink
folly: build with -Wunused-parameter
Browse files Browse the repository at this point in the history
Summary: Mechanical changes (using custom clang-tidy) to fix all of the `-Wunused-parameter` violations in folly.

Reviewed By: yfeldblum

Differential Revision: D2872406

fb-gh-sync-id: bdb1941f3dadf6ab854e7a9f271f50fda93f9480
  • Loading branch information
igorsugak authored and facebook-github-bot-0 committed Jan 28, 2016
1 parent 08391a0 commit a1614fe
Show file tree
Hide file tree
Showing 86 changed files with 621 additions and 565 deletions.
6 changes: 3 additions & 3 deletions folly/ApplyTuple.h
Expand Up @@ -81,10 +81,10 @@ struct CallTuple {
);
}

template<class F, class Tuple, class ...Unpacked>
template <class F, class Tuple, class... Unpacked>
static typename std::enable_if<ExprIsUnpacked<Tuple, Unpacked...>::value,
Ret
>::type call(const F& f, Tuple&& t, Unpacked&&... unp) {
Ret>::type
call(const F& f, Tuple&& /* t */, Unpacked&&... unp) {
return makeCallable(f)(std::forward<Unpacked>(unp)...);
}
};
Expand Down
8 changes: 3 additions & 5 deletions folly/Arena.h
Expand Up @@ -99,7 +99,7 @@ class Arena {
return r;
}

void deallocate(void* p) {
void deallocate(void* /* p */) {
// Deallocate? Never!
}

Expand Down Expand Up @@ -215,14 +215,12 @@ struct IsArenaAllocator<Arena<Alloc>> : std::true_type { };
*/
template <class Alloc>
struct ArenaAllocatorTraits {
static size_t goodSize(const Alloc& alloc, size_t size) {
return size;
}
static size_t goodSize(const Alloc& /* alloc */, size_t size) { return size; }
};

template <>
struct ArenaAllocatorTraits<SysAlloc> {
static size_t goodSize(const SysAlloc& alloc, size_t size) {
static size_t goodSize(const SysAlloc& /* alloc */, size_t size) {
return goodMallocSize(size);
}
};
Expand Down
11 changes: 7 additions & 4 deletions folly/AtomicHashArray.h
Expand Up @@ -44,7 +44,9 @@ namespace folly {

struct AtomicHashArrayLinearProbeFcn
{
inline size_t operator()(size_t idx, size_t numProbes, size_t capacity) const{
inline size_t operator()(size_t idx,
size_t /* numProbes */,
size_t capacity) const {
idx += 1; // linear probing

// Avoid modulus because it's slow
Expand Down Expand Up @@ -75,9 +77,10 @@ class AHAIdentity {
};

template <typename NotKeyT, typename KeyT>
inline void checkLegalKeyIfKeyTImpl(NotKeyT ignored, KeyT emptyKey,
KeyT lockedKey, KeyT erasedKey) {
}
inline void checkLegalKeyIfKeyTImpl(NotKeyT /* ignored */,
KeyT /* emptyKey */,
KeyT /* lockedKey */,
KeyT /* erasedKey */) {}

template <typename KeyT>
inline void checkLegalKeyIfKeyTImpl(KeyT key_in, KeyT emptyKey,
Expand Down
2 changes: 1 addition & 1 deletion folly/AtomicUnorderedMap.h
Expand Up @@ -178,7 +178,7 @@ struct AtomicUnorderedInsertMap {
}

// post-increment
ConstIterator operator++ (int dummy) {
ConstIterator operator++(int /* dummy */) {
auto prev = *this;
++*this;
return prev;
Expand Down
3 changes: 1 addition & 2 deletions folly/Benchmark.h
Expand Up @@ -260,8 +260,7 @@ void doNotOptimizeAway(T&& datum) {
#elif defined(__clang__)

template <class T>
__attribute__((__optnone__)) void doNotOptimizeAway(T&& datum) {
}
__attribute__((__optnone__)) void doNotOptimizeAway(T&& /* datum */) {}

#else

Expand Down
2 changes: 1 addition & 1 deletion folly/ConcurrentSkipList-inl.h
Expand Up @@ -322,7 +322,7 @@ class NodeRecycler<NodeType, NodeAlloc, typename std::enable_if<
void addRef() { }
void releaseRef() { }

void add(NodeType* node) { }
void add(NodeType* /* node */) {}

NodeAlloc& alloc() { return alloc_; }

Expand Down
31 changes: 14 additions & 17 deletions folly/Conv.h
Expand Up @@ -388,8 +388,8 @@ estimateSpaceNeeded(Src value) {
return folly::StringPiece(value).size();
}

template<>
inline size_t estimateSpaceNeeded(std::nullptr_t value) {
template <>
inline size_t estimateSpaceNeeded(std::nullptr_t /* value */) {
return 0;
}

Expand Down Expand Up @@ -754,9 +754,8 @@ toAppendStrImpl(const T& v, const Ts&... vs) {

template <class Delimiter, class T, class Tgt>
typename std::enable_if<
IsSomeString<typename std::remove_pointer<Tgt>::type>
::value>::type
toAppendDelimStrImpl(const Delimiter& delim, const T& v, Tgt result) {
IsSomeString<typename std::remove_pointer<Tgt>::type>::value>::type
toAppendDelimStrImpl(const Delimiter& /* delim */, const T& v, Tgt result) {
toAppend(v, result);
}

Expand Down Expand Up @@ -821,24 +820,22 @@ void toAppendFit(const Ts&) {}
* Variadic base case: do nothing.
*/
template <class Tgt>
typename std::enable_if<IsSomeString<Tgt>::value>::type
toAppend(Tgt* result) {
}
typename std::enable_if<IsSomeString<Tgt>::value>::type toAppend(
Tgt* /* result */) {}

/**
* Variadic base case: do nothing.
*/
template <class Delimiter, class Tgt>
typename std::enable_if<IsSomeString<Tgt>::value>::type
toAppendDelim(const Delimiter& delim, Tgt* result) {
}
typename std::enable_if<IsSomeString<Tgt>::value>::type toAppendDelim(
const Delimiter& /* delim */, Tgt* /* result */) {}

/**
* 1 element: same as toAppend.
*/
template <class Delimiter, class T, class Tgt>
typename std::enable_if<IsSomeString<Tgt>::value>::type
toAppendDelim(const Delimiter& delim, const T& v, Tgt* tgt) {
typename std::enable_if<IsSomeString<Tgt>::value>::type toAppendDelim(
const Delimiter& /* delim */, const T& v, Tgt* tgt) {
toAppend(v, tgt);
}

Expand Down Expand Up @@ -893,10 +890,10 @@ to(const Ts&... vs) {
* toDelim<SomeString>(SomeString str) returns itself.
*/
template <class Tgt, class Delim, class Src>
typename std::enable_if<
IsSomeString<Tgt>::value && std::is_same<Tgt, Src>::value,
Tgt>::type
toDelim(const Delim& delim, const Src & value) {
typename std::enable_if<IsSomeString<Tgt>::value &&
std::is_same<Tgt, Src>::value,
Tgt>::type
toDelim(const Delim& /* delim */, const Src& value) {
return value;
}

Expand Down
4 changes: 2 additions & 2 deletions folly/DynamicConverter.h
Expand Up @@ -115,8 +115,8 @@ namespace dynamicconverter_detail {

template<typename T>
struct Dereferencer {
static inline void
derefToCache(T* mem, const dynamic::const_item_iterator& it) {
static inline void derefToCache(
T* /* mem */, const dynamic::const_item_iterator& /* it */) {
throw TypeError("array", dynamic::Type::OBJECT);
}

Expand Down
15 changes: 10 additions & 5 deletions folly/FBString.h
Expand Up @@ -1038,8 +1038,10 @@ class basic_fbstring {
}
#endif

basic_fbstring(const basic_fbstring& str, size_type pos,
size_type n = npos, const A& a = A()) {
basic_fbstring(const basic_fbstring& str,
size_type pos,
size_type n = npos,
const A& /* a */ = A()) {
assign(str, pos, n);
}

Expand Down Expand Up @@ -1682,9 +1684,12 @@ class basic_fbstring {
}

private:
template <class FwdIterator>
bool replaceAliased(iterator i1, iterator i2,
FwdIterator s1, FwdIterator s2, std::false_type) {
template <class FwdIterator>
bool replaceAliased(iterator /* i1 */,
iterator /* i2 */,
FwdIterator /* s1 */,
FwdIterator /* s2 */,
std::false_type) {
return false;
}

Expand Down
8 changes: 5 additions & 3 deletions folly/Format-inl.h
Expand Up @@ -771,7 +771,9 @@ template <class T, class = void>
class TryFormatValue {
public:
template <class FormatCallback>
static void formatOrFail(T& value, FormatArg& arg, FormatCallback& cb) {
static void formatOrFail(T& /* value */,
FormatArg& arg,
FormatCallback& /* cb */) {
arg.error("No formatter available for this type");
}
};
Expand Down Expand Up @@ -1047,8 +1049,8 @@ class FormatValue<std::tuple<Args...>> {
static constexpr size_t valueCount = std::tuple_size<Tuple>::value;

template <size_t K, class Callback>
typename std::enable_if<K == valueCount>::type
doFormatFrom(size_t i, FormatArg& arg, Callback& cb) const {
typename std::enable_if<K == valueCount>::type doFormatFrom(
size_t i, FormatArg& arg, Callback& /* cb */) const {
arg.enforce("tuple index out of range, max=", i);
}

Expand Down
6 changes: 2 additions & 4 deletions folly/Memory.h
Expand Up @@ -202,13 +202,11 @@ class StlAllocator {
template <class U> StlAllocator(const StlAllocator<Alloc, U>& other)
: alloc_(other.alloc()) { }

T* allocate(size_t n, const void* hint = nullptr) {
T* allocate(size_t n, const void* /* hint */ = nullptr) {
return static_cast<T*>(alloc_->allocate(n * sizeof(T)));
}

void deallocate(T* p, size_t n) {
alloc_->deallocate(p);
}
void deallocate(T* p, size_t /* n */) { alloc_->deallocate(p); }

size_t max_size() const {
return std::numeric_limits<size_t>::max();
Expand Down
4 changes: 3 additions & 1 deletion folly/SharedMutex.h
Expand Up @@ -496,7 +496,9 @@ class SharedMutexImpl {
bool canTimeOut() { return true; }
bool shouldTimeOut() { return true; }

bool doWait(Futex& futex, uint32_t expected, uint32_t waitMask) {
bool doWait(Futex& /* futex */,
uint32_t /* expected */,
uint32_t /* waitMask */) {
return false;
}
};
Expand Down
9 changes: 4 additions & 5 deletions folly/Singleton.h
Expand Up @@ -528,10 +528,9 @@ class Singleton {
return getEntry().try_get_fast();
}

explicit Singleton(std::nullptr_t _ = nullptr,
typename Singleton::TeardownFunc t = nullptr) :
Singleton ([]() { return new T; }, std::move(t)) {
}
explicit Singleton(std::nullptr_t /* _ */ = nullptr,
typename Singleton::TeardownFunc t = nullptr)
: Singleton([]() { return new T; }, std::move(t)) {}

explicit Singleton(typename Singleton::CreateFunc c,
typename Singleton::TeardownFunc t = nullptr) {
Expand Down Expand Up @@ -577,7 +576,7 @@ class Singleton {
* the injection. The returned mock singleton is functionality identical to
* regular singletons.
*/
static void make_mock(std::nullptr_t c = nullptr,
static void make_mock(std::nullptr_t /* c */ = nullptr,
typename Singleton<T>::TeardownFunc t = nullptr) {
make_mock([]() { return new T; }, t);
}
Expand Down
2 changes: 1 addition & 1 deletion folly/ThreadCachedArena.h
Expand Up @@ -52,7 +52,7 @@ class ThreadCachedArena {
return arena->allocate(size);
}

void deallocate(void* p) {
void deallocate(void* /* p */) {
// Deallocate? Never!
}

Expand Down
2 changes: 1 addition & 1 deletion folly/ThreadName.h
Expand Up @@ -31,7 +31,7 @@ namespace folly {
#endif

template <typename T>
inline bool setThreadName(T id, StringPiece name) {
inline bool setThreadName(T /* id */, StringPiece /* name */) {
static_assert(
std::is_same<T, pthread_t>::value ||
std::is_same<T, std::thread::native_handle_type>::value,
Expand Down
2 changes: 1 addition & 1 deletion folly/detail/CacheLocality.cpp
Expand Up @@ -259,7 +259,7 @@ AccessSpreaderArray<std::atomic,128>
AccessSpreaderArray<std::atomic,128>::sharedInstance = {};

/// Always claims to be on CPU zero, node zero
static int degenerateGetcpu(unsigned* cpu, unsigned* node, void* unused) {
static int degenerateGetcpu(unsigned* cpu, unsigned* node, void* /* unused */) {
if (cpu != nullptr) {
*cpu = 0;
}
Expand Down
2 changes: 1 addition & 1 deletion folly/detail/CacheLocality.h
Expand Up @@ -179,7 +179,7 @@ struct FallbackGetcpu {
/// Fills the thread id into the cpu and node out params (if they
/// are non-null). This method is intended to act like getcpu when a
/// fast-enough form of getcpu isn't available or isn't desired
static int getcpu(unsigned* cpu, unsigned* node, void* unused) {
static int getcpu(unsigned* cpu, unsigned* node, void* /* unused */) {
auto id = ThreadId::get();
if (cpu) {
*cpu = id;
Expand Down
4 changes: 2 additions & 2 deletions folly/detail/DiscriminatedPtrDetail.h
Expand Up @@ -115,7 +115,7 @@ template <typename V, typename R, typename... Types> struct ApplyVisitor1;

template <typename V, typename R>
struct ApplyVisitor1<V, R> {
R operator()(size_t index, V&& visitor, void* ptr) const {
R operator()(size_t /* index */, V&& /* visitor */, void* /* ptr */) const {
CHECK(false); // NOTREACHED
}
};
Expand All @@ -133,7 +133,7 @@ template <typename V, typename R, typename... Types> struct ApplyConstVisitor1;

template <typename V, typename R>
struct ApplyConstVisitor1<V, R> {
R operator()(size_t index, V&& visitor, void* ptr) const {
R operator()(size_t /* index */, V&& /* visitor */, void* /* ptr */) const {
CHECK(false); // NOTREACHED
}
};
Expand Down
2 changes: 1 addition & 1 deletion folly/detail/FileUtilDetail.h
Expand Up @@ -38,7 +38,7 @@ ssize_t wrapNoInt(F f, Args... args) {
return r;
}

inline void incr(ssize_t n) { }
inline void incr(ssize_t /* n */) {}
inline void incr(ssize_t n, off_t& offset) { offset += n; }

// Wrap call to read/pread/write/pwrite(fd, buf, count, offset?) to retry on
Expand Down
4 changes: 3 additions & 1 deletion folly/dynamic-inl.h
Expand Up @@ -731,7 +731,9 @@ struct dynamic::PrintImpl {
// Otherwise, null, being (void*)0, would print as 0.
template <>
struct dynamic::PrintImpl<void*> {
static void print(dynamic const& d, std::ostream& out, void* const& nul) {
static void print(dynamic const& /* d */,
std::ostream& out,
void* const& nul) {
DCHECK_EQ((void*)0, nul);
out << "null";
}
Expand Down
4 changes: 1 addition & 3 deletions folly/experimental/Instructions.h
Expand Up @@ -30,9 +30,7 @@ namespace folly { namespace compression { namespace instructions {
// use explicitly.

struct Default {
static bool supported(const folly::CpuId& cpuId = {}) {
return true;
}
static bool supported(const folly::CpuId& /* cpuId */ = {}) { return true; }
static inline uint64_t popcount(uint64_t value) {
return __builtin_popcountll(value);
}
Expand Down
2 changes: 1 addition & 1 deletion folly/experimental/NestedCommandLineApp.cpp
Expand Up @@ -96,7 +96,7 @@ void NestedCommandLineApp::addAlias(std::string newName,
}

void NestedCommandLineApp::displayHelp(
const po::variables_map& globalOptions,
const po::variables_map& /* globalOptions */,
const std::vector<std::string>& args) {
if (args.empty()) {
// General help
Expand Down
8 changes: 4 additions & 4 deletions folly/experimental/ProgramOptions.cpp
Expand Up @@ -87,7 +87,7 @@ class GFlagValueSemanticBase : public po::value_semantic {
bool is_composing() const override { return false; }
bool is_required() const override { return false; }
// We handle setting the GFlags from parse(), so notify() does nothing.
void notify(const boost::any& valueStore) const override { }
void notify(const boost::any& /* valueStore */) const override {}
bool apply_default(boost::any& valueStore) const override {
// We're using the *current* rather than *default* value here, and
// this is intentional; GFlags-using programs assign to FLAGS_foo
Expand All @@ -101,19 +101,19 @@ class GFlagValueSemanticBase : public po::value_semantic {

void parse(boost::any& valueStore,
const std::vector<std::string>& tokens,
bool utf8) const override;
bool /* utf8 */) const override;

private:
virtual T parseValue(const std::vector<std::string>& tokens) const = 0;
virtual void transform(T& val) const { }
virtual void transform(T& /* val */) const {}

mutable std::shared_ptr<GFlagInfo<T>> info_;
};

template <class T>
void GFlagValueSemanticBase<T>::parse(boost::any& valueStore,
const std::vector<std::string>& tokens,
bool utf8) const {
bool /* utf8 */) const {
T val;
try {
val = this->parseValue(tokens);
Expand Down

0 comments on commit a1614fe

Please sign in to comment.