From 79b19aacf0d7edae91765bda58b742747ab57ed4 Mon Sep 17 00:00:00 2001 From: "Adam C. Emerson" Date: Fri, 22 Dec 2017 19:36:09 -0500 Subject: [PATCH] {common,osd,mds,rbd}: Remove unused captures If we aren't referencing a variable, don't capture it. (This makes the lambdas smaller, too, modulo Sufficiently Smart Compiler.) Signed-off-by: Adam C. Emerson --- src/common/Throttle.h | 2 +- src/mds/MDBalancer.cc | 2 +- src/mds/MDCache.cc | 2 +- src/mds/MDSRank.cc | 6 +++--- src/mon/MgrStatMonitor.cc | 2 +- src/mon/MonmapMonitor.cc | 2 +- src/osd/PrimaryLogPG.cc | 2 +- src/test/librbd/io/test_mock_ObjectRequest.cc | 3 +-- src/test/librbd/test_librbd.cc | 2 +- src/test/rbd_mirror/test_mock_ImageSync.cc | 4 ++-- 10 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/common/Throttle.h b/src/common/Throttle.h index 9081c006b774..8c6d13afeec2 100644 --- a/src/common/Throttle.h +++ b/src/common/Throttle.h @@ -384,7 +384,7 @@ public: uint64_t got = m_throttle.get(c); if (got < c) { // Not enough tokens, add a blocker for it. - Context *ctx = new FunctionContext([this, handler, item](int r) { + Context *ctx = new FunctionContext([handler, item](int r) { (handler->*MF)(r, item); }); m_blockers.emplace_back(c - got, ctx); diff --git a/src/mds/MDBalancer.cc b/src/mds/MDBalancer.cc index 4801f8f5abf0..88fdc722fa90 100644 --- a/src/mds/MDBalancer.cc +++ b/src/mds/MDBalancer.cc @@ -1292,7 +1292,7 @@ int MDBalancer::dump_loads(Formatter *f) f->open_object_section("mds_load"); { - auto dump_mds_load = [this, f, now](mds_load_t& load) { + auto dump_mds_load = [f, now](mds_load_t& load) { f->dump_float("request_rate", load.req_rate); f->dump_float("cache_hit_rate", load.cache_hit_rate); f->dump_float("queue_length", load.queue_len); diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc index c58ce5d6520d..7803df70e7ac 100644 --- a/src/mds/MDCache.cc +++ b/src/mds/MDCache.cc @@ -11985,7 +11985,7 @@ int MDCache::dump_cache(const char *fn, Formatter *f, } } - auto dump_func = [this, fd, f, depth, &dump_root](CInode *in) { + auto dump_func = [fd, f, depth, &dump_root](CInode *in) { int r; if (!dump_root.empty()) { string ipath; diff --git a/src/mds/MDSRank.cc b/src/mds/MDSRank.cc index fe4aaf269665..59c9d5e0b508 100644 --- a/src/mds/MDSRank.cc +++ b/src/mds/MDSRank.cc @@ -1365,7 +1365,7 @@ void MDSRank::reconnect_start() objecter->enable_blacklist_events(); std::set blacklist; epoch_t epoch = 0; - objecter->with_osdmap([this, &blacklist, &epoch](const OSDMap& o) { + objecter->with_osdmap([&blacklist, &epoch](const OSDMap& o) { o.get_blacklist(&blacklist); epoch = o.get_epoch(); }); @@ -2743,7 +2743,7 @@ bool MDSRank::evict_client(int64_t session_id, Context *on_blacklist_done = new FunctionContext([this, session_id, fn](int r) { objecter->wait_for_latest_osdmap( new C_OnFinisher( - new FunctionContext([this, session_id, fn](int r) { + new FunctionContext([this, fn](int r) { Mutex::Locker l(mds_lock); auto epoch = objecter->with_osdmap([](const OSDMap &o){ return o.get_epoch(); @@ -2760,7 +2760,7 @@ bool MDSRank::evict_client(int64_t session_id, monc->start_mon_command(cmd, {}, nullptr, nullptr, on_blacklist_done); }; - auto blocking_blacklist = [this, cmd, &err_ss, background_blacklist](){ + auto blocking_blacklist = [this, cmd, background_blacklist](){ C_SaferCond inline_ctx; background_blacklist([&inline_ctx](){inline_ctx.complete(0);}); mds_lock.Unlock(); diff --git a/src/mon/MgrStatMonitor.cc b/src/mon/MgrStatMonitor.cc index 0d4ca3e7e10e..471f9748cd7d 100644 --- a/src/mon/MgrStatMonitor.cc +++ b/src/mon/MgrStatMonitor.cc @@ -265,7 +265,7 @@ void MgrStatMonitor::check_sub(Subscription *sub) auto m = new MServiceMap(service_map); sub->session->con->send_message(m); if (sub->onetime) { - mon->with_session_map([this, sub](MonSessionMap& session_map) { + mon->with_session_map([sub](MonSessionMap& session_map) { session_map.remove_sub(sub); }); } else { diff --git a/src/mon/MonmapMonitor.cc b/src/mon/MonmapMonitor.cc index 88e5e1731a36..f84c930e5df3 100644 --- a/src/mon/MonmapMonitor.cc +++ b/src/mon/MonmapMonitor.cc @@ -769,7 +769,7 @@ void MonmapMonitor::check_sub(Subscription *sub) if (sub->next <= epoch) { mon->send_latest_monmap(sub->session->con.get()); if (sub->onetime) { - mon->with_session_map([this, sub](MonSessionMap& session_map) { + mon->with_session_map([sub](MonSessionMap& session_map) { session_map.remove_sub(sub); }); } else { diff --git a/src/osd/PrimaryLogPG.cc b/src/osd/PrimaryLogPG.cc index f06deacf222a..0e8c473dcda2 100644 --- a/src/osd/PrimaryLogPG.cc +++ b/src/osd/PrimaryLogPG.cc @@ -3845,7 +3845,7 @@ void PrimaryLogPG::execute_ctx(OpContext *ctx) ConnectionRef()); }); ctx->register_on_finish( - [ctx, this]() { + [ctx]() { delete ctx; }); diff --git a/src/test/librbd/io/test_mock_ObjectRequest.cc b/src/test/librbd/io/test_mock_ObjectRequest.cc index 6f0425029ec0..09c48f0dc70b 100644 --- a/src/test/librbd/io/test_mock_ObjectRequest.cc +++ b/src/test/librbd/io/test_mock_ObjectRequest.cc @@ -208,8 +208,7 @@ struct TestMockIoObjectRequest : public TestMockFixture { void expect_copyup(MockCopyupRequest& mock_copyup_request, int r) { EXPECT_CALL(mock_copyup_request, send()) - .WillOnce(Invoke([&mock_copyup_request, r]() { - })); + .WillOnce(Invoke([]() {})); } void expect_copyup(MockCopyupRequest& mock_copyup_request, diff --git a/src/test/librbd/test_librbd.cc b/src/test/librbd/test_librbd.cc index 5968f42c2a13..7d019b4333f4 100644 --- a/src/test/librbd/test_librbd.cc +++ b/src/test/librbd/test_librbd.cc @@ -6172,7 +6172,7 @@ TEST_F(TestLibRBD, ExclusiveLock) int owner_id = -1; mutex lock; - const auto pingpong = [&,this](int m_id, rbd_image_t &m_image) { + const auto pingpong = [&](int m_id, rbd_image_t &m_image) { for (int i = 0; i < 10; i++) { { lock_guard locker(lock); diff --git a/src/test/rbd_mirror/test_mock_ImageSync.cc b/src/test/rbd_mirror/test_mock_ImageSync.cc index aed32bbfb48b..69c141df60cb 100644 --- a/src/test/rbd_mirror/test_mock_ImageSync.cc +++ b/src/test/rbd_mirror/test_mock_ImageSync.cc @@ -330,14 +330,14 @@ TEST_F(TestMockImageSync, CancelNotifySyncRequest) { C_SaferCond notify_sync_ctx; EXPECT_CALL(mock_instance_watcher, notify_sync_request(mock_local_image_ctx.id, _)) - .WillOnce(Invoke([this, &on_sync_start, ¬ify_sync_ctx]( + .WillOnce(Invoke([&on_sync_start, ¬ify_sync_ctx]( const std::string &, Context *ctx) { on_sync_start = ctx; notify_sync_ctx.complete(0); })); EXPECT_CALL(mock_instance_watcher, cancel_sync_request(mock_local_image_ctx.id)) - .WillOnce(Invoke([this, &on_sync_start](const std::string &) { + .WillOnce(Invoke([&on_sync_start](const std::string &) { EXPECT_NE(nullptr, on_sync_start); on_sync_start->complete(-ECANCELED); return true; -- 2.47.3