From 7fc1994339d24d7ad417b7caf0d8be049f750380 Mon Sep 17 00:00:00 2001 From: Kurtis Rader Date: Mon, 13 Feb 2017 18:48:59 -0800 Subject: [PATCH] some trivial lint cleanups --- src/common.h | 5 +---- src/complete.cpp | 2 +- src/fallback.cpp | 6 +++--- src/fish_tests.cpp | 2 +- src/iothread.cpp | 8 ++++---- src/lru.h | 4 ++-- 6 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/common.h b/src/common.h index 0d1ee5777..16798a130 100644 --- a/src/common.h +++ b/src/common.h @@ -637,7 +637,7 @@ class owning_lock { DATA data; public: - owning_lock(DATA d) : data(std::move(d)) {} + owning_lock(DATA &&d) : data(std::move(d)) {} owning_lock() : data() {} acquired_lock acquire() { return {lock, &data}; } @@ -826,9 +826,6 @@ void assert_is_not_forked_child(const char *who); #define ASSERT_IS_NOT_FORKED_CHILD_TRAMPOLINE(x) assert_is_not_forked_child(x) #define ASSERT_IS_NOT_FORKED_CHILD() ASSERT_IS_NOT_FORKED_CHILD_TRAMPOLINE(__FUNCTION__) -/// Macro to help suppress potentially unused variable warnings. -#define USE(var) (void)(var) - extern "C" { __attribute__((noinline)) void debug_thread_error(void); } diff --git a/src/complete.cpp b/src/complete.cpp index 3b9ae7f72..50e890617 100644 --- a/src/complete.cpp +++ b/src/complete.cpp @@ -667,7 +667,7 @@ void completer_t::complete_cmd(const wcstring &str_cmd, bool use_function, bool expand_error_t ignore = expand_string(str_cmd, &this->completions, EXPAND_FOR_COMPLETIONS | DIRECTORIES_ONLY | this->expand_flags(), NULL); - USE(ignore); + UNUSED(ignore); } if (str_cmd.find(L'/') == wcstring::npos && str_cmd.at(0) != L'~') { diff --git a/src/fallback.cpp b/src/fallback.cpp index 5570f06f5..20af4fd5f 100644 --- a/src/fallback.cpp +++ b/src/fallback.cpp @@ -216,9 +216,9 @@ wchar_t *wcsndup(const wchar_t *in, size_t c) { * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ size_t wcslcpy(wchar_t *dst, const wchar_t *src, size_t siz) { - register wchar_t *d = dst; - register const wchar_t *s = src; - register size_t n = siz; + wchar_t *d = dst; + const wchar_t *s = src; + size_t n = siz; // Copy as many bytes as will fit. if (n != 0 && --n != 0) { diff --git a/src/fish_tests.cpp b/src/fish_tests.cpp index 7e945b7af..3a055ad13 100644 --- a/src/fish_tests.cpp +++ b/src/fish_tests.cpp @@ -1136,7 +1136,7 @@ class test_lru_t : public lru_cache_t { std::vector evicted; - void entry_was_evicted(wcstring key, int val) { evicted.push_back({key, val}); } + void entry_was_evicted(const wcstring &key, int val) { evicted.push_back({key, val}); } std::vector values() const { std::vector result; diff --git a/src/iothread.cpp b/src/iothread.cpp index 7ad527c72..81dd8537d 100644 --- a/src/iothread.cpp +++ b/src/iothread.cpp @@ -40,8 +40,8 @@ struct spawn_request_t { spawn_request_t() {} - spawn_request_t(void_function_t f, void_function_t comp) - : handler(std::move(f)), completion(std::move(comp)) {} + spawn_request_t(void_function_t &&f, void_function_t &&comp) + : handler(f), completion(comp) {} // Move-only spawn_request_t &operator=(const spawn_request_t &) = delete; @@ -54,7 +54,7 @@ struct main_thread_request_t { volatile bool done = false; void_function_t func; - main_thread_request_t(void_function_t f) : func(std::move(f)) {} + main_thread_request_t(void_function_t &&f) : func(f) {} // No moving OR copying // main_thread_requests are always stack allocated, and we deal in pointers to them @@ -309,7 +309,7 @@ static void iothread_service_result_queue() { // Perform each completion in order while (!result_queue.empty()) { - spawn_request_t req = std::move(result_queue.front()); + spawn_request_t req(std::move(result_queue.front())); result_queue.pop(); // ensure we don't invoke empty functions, that raises an exception if (req.completion != nullptr) { diff --git a/src/lru.h b/src/lru.h index 860353eb1..c3159c8f3 100644 --- a/src/lru.h +++ b/src/lru.h @@ -108,8 +108,8 @@ class lru_cache_t { // CRTP callback for when a node is evicted. // Clients can implement this void entry_was_evicted(wcstring key, CONTENTS value) { - USE(key); - USE(value); + UNUSED(key); + UNUSED(value); } // Implementation of merge step for mergesort