From 2e99fd85faeabf22ed1d8c58f796410be76728df Mon Sep 17 00:00:00 2001 From: Francesco Chemolli <5175948+kinkie@users.noreply.github.com> Date: Sun, 1 Dec 2024 01:50:07 +0000 Subject: [PATCH] NoNewGlobals for Comm::AcceptLimiter::Instance_ (#1954) Inspired by Coverity. CID 1441988: Useless call (USELESS_CALL). --- src/comm.cc | 3 --- src/comm/AcceptLimiter.cc | 5 ++--- src/comm/AcceptLimiter.h | 2 -- 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/comm.cc b/src/comm.cc index 24fe6ce462c..c5f4751bc78 100644 --- a/src/comm.cc +++ b/src/comm.cc @@ -1154,9 +1154,6 @@ comm_init(void) { assert(fd_table); - /* make sure the accept() socket FIFO delay queue exists */ - Comm::AcceptLimiter::Instance(); - // make sure the IO pending callback table exists Comm::CallbackTableInit(); diff --git a/src/comm/AcceptLimiter.cc b/src/comm/AcceptLimiter.cc index a303592b899..6df2bd2a058 100644 --- a/src/comm/AcceptLimiter.cc +++ b/src/comm/AcceptLimiter.cc @@ -13,12 +13,11 @@ #include "fde.h" #include "globals.h" -Comm::AcceptLimiter Comm::AcceptLimiter::Instance_; - Comm::AcceptLimiter & Comm::AcceptLimiter::Instance() { - return Instance_; + static const auto Instance_ = new AcceptLimiter(); + return *Instance_; } void diff --git a/src/comm/AcceptLimiter.h b/src/comm/AcceptLimiter.h index 6f18c9a8b1c..e5e1435ccc4 100644 --- a/src/comm/AcceptLimiter.h +++ b/src/comm/AcceptLimiter.h @@ -43,8 +43,6 @@ class AcceptLimiter void kick(); private: - static AcceptLimiter Instance_; - /** FIFO queue */ std::deque deferred_; };