summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorEd Tanous <edtanous@google.com>2022-12-21 20:30:16 +0300
committerEd Tanous <ed@tanous.net>2023-01-17 19:44:09 +0300
commitcf9e417d3b88eb12f8c6a9d007d6a63c3eeb94f4 (patch)
tree45344ba086e93c7ff5589f9328b2c942679114ba /include
parent0d9462115c53d478ed757ca4a3cccd0acf593781 (diff)
downloadbmcweb-cf9e417d3b88eb12f8c6a9d007d6a63c3eeb94f4.tar.xz
Add check for globals
We don't follow this cpp core guidelines rule well. This is something that we should aspire to cleaning up in the future, but for the moment, lets turn the rule on in clang-tidy to stop the bleeding, add ignores for the things that we know need some better abstractions, and work on these over time. Most of this commit is just adding NOLINTNEXTLINE exceptions for all of our globals. There was one case in the sensor code where clang correctly noted that those globals weren't actually const, which got missed because of the use of auto. Tested: CI should be good enough for this. Passes clang-tidy. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ieda08fee69a3b209d4b3e9771809a6c41524f066
Diffstat (limited to 'include')
-rw-r--r--include/dbus_monitor.hpp8
-rw-r--r--include/dbus_singleton.hpp1
-rw-r--r--include/forward_unauthorized.hpp1
-rw-r--r--include/hostname_monitor.hpp1
-rw-r--r--include/image_upload.hpp1
-rw-r--r--include/kvm_websocket.hpp7
-rw-r--r--include/nbd_proxy.hpp9
-rw-r--r--include/obmc_console.hpp5
-rw-r--r--include/vm_websocket.hpp2
-rw-r--r--include/webroutes.hpp1
10 files changed, 26 insertions, 10 deletions
diff --git a/include/dbus_monitor.hpp b/include/dbus_monitor.hpp
index 0838f0ae6c..3bad07002d 100644
--- a/include/dbus_monitor.hpp
+++ b/include/dbus_monitor.hpp
@@ -24,9 +24,11 @@ struct DbusWebsocketSession
interfaces;
};
-static boost::container::flat_map<crow::websocket::Connection*,
- DbusWebsocketSession>
- sessions;
+using SessionMap = boost::container::flat_map<crow::websocket::Connection*,
+ DbusWebsocketSession>;
+
+// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
+static SessionMap sessions;
inline int onPropertyUpdate(sd_bus_message* m, void* userdata,
sd_bus_error* retError)
diff --git a/include/dbus_singleton.hpp b/include/dbus_singleton.hpp
index 283021641b..f9b50b078d 100644
--- a/include/dbus_singleton.hpp
+++ b/include/dbus_singleton.hpp
@@ -9,6 +9,7 @@ namespace connections
// Initialze before using!
// Please see webserver_main for the example how this variable is initialzed,
+// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
extern sdbusplus::asio::connection* systemBus;
} // namespace connections
diff --git a/include/forward_unauthorized.hpp b/include/forward_unauthorized.hpp
index 2fc3ee45f5..850a0b79b0 100644
--- a/include/forward_unauthorized.hpp
+++ b/include/forward_unauthorized.hpp
@@ -6,6 +6,7 @@
namespace forward_unauthorized
{
+// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
static bool hasWebuiRoute = false;
inline void sendUnauthorized(std::string_view url,
diff --git a/include/hostname_monitor.hpp b/include/hostname_monitor.hpp
index 3fb42e49c0..cb84ad67d0 100644
--- a/include/hostname_monitor.hpp
+++ b/include/hostname_monitor.hpp
@@ -11,6 +11,7 @@ namespace crow
{
namespace hostname_monitor
{
+// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
static std::unique_ptr<sdbusplus::bus::match_t> hostnameSignalMonitor;
inline void installCertificate(const std::filesystem::path& certPath)
diff --git a/include/image_upload.hpp b/include/image_upload.hpp
index 4defbb6682..bdb7b951ac 100644
--- a/include/image_upload.hpp
+++ b/include/image_upload.hpp
@@ -16,6 +16,7 @@ namespace crow
namespace image_upload
{
+// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
static std::unique_ptr<sdbusplus::bus::match_t> fwUpdateMatcher;
inline void
diff --git a/include/kvm_websocket.hpp b/include/kvm_websocket.hpp
index 79975d2c01..1a067ac0fc 100644
--- a/include/kvm_websocket.hpp
+++ b/include/kvm_websocket.hpp
@@ -150,9 +150,10 @@ class KvmSession
bool doingWrite{false};
};
-static boost::container::flat_map<crow::websocket::Connection*,
- std::unique_ptr<KvmSession>>
- sessions;
+using SessionMap = boost::container::flat_map<crow::websocket::Connection*,
+ std::unique_ptr<KvmSession>>;
+// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
+static SessionMap sessions;
inline void requestRoutes(App& app)
{
diff --git a/include/nbd_proxy.hpp b/include/nbd_proxy.hpp
index ac3a8113c1..68491cb86b 100644
--- a/include/nbd_proxy.hpp
+++ b/include/nbd_proxy.hpp
@@ -34,7 +34,7 @@ namespace nbd_proxy
using boost::asio::local::stream_protocol;
static constexpr auto nbdBufferSize = 131088;
-static const char* requiredPrivilegeString = "ConfigureManager";
+constexpr const char* requiredPrivilegeString = "ConfigureManager";
struct NbdProxyServer : std::enable_shared_from_this<NbdProxyServer>
{
@@ -247,9 +247,10 @@ struct NbdProxyServer : std::enable_shared_from_this<NbdProxyServer>
crow::websocket::Connection& connection;
};
-static boost::container::flat_map<crow::websocket::Connection*,
- std::shared_ptr<NbdProxyServer>>
- sessions;
+using SessionMap = boost::container::flat_map<crow::websocket::Connection*,
+ std::shared_ptr<NbdProxyServer>>;
+// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
+static SessionMap sessions;
inline void requestRoutes(App& app)
{
diff --git a/include/obmc_console.hpp b/include/obmc_console.hpp
index d5eaf819e7..b8f69435fc 100644
--- a/include/obmc_console.hpp
+++ b/include/obmc_console.hpp
@@ -12,13 +12,18 @@ namespace crow
namespace obmc_console
{
+// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
static std::unique_ptr<boost::asio::local::stream_protocol::socket> hostSocket;
+// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
static std::array<char, 4096> outputBuffer;
+// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
static std::string inputBuffer;
+// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
static boost::container::flat_set<crow::websocket::Connection*> sessions;
+// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
static bool doingWrite = false;
inline void doWrite()
diff --git a/include/vm_websocket.hpp b/include/vm_websocket.hpp
index ebf0a698e1..1d3bf96c4c 100644
--- a/include/vm_websocket.hpp
+++ b/include/vm_websocket.hpp
@@ -14,6 +14,7 @@ namespace crow
namespace obmc_vm
{
+// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
static crow::websocket::Connection* session = nullptr;
// The max network block device buffer size is 128kb plus 16bytes
@@ -157,6 +158,7 @@ class Handler : public std::enable_shared_from_this<Handler>
inputBuffer;
};
+// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
static std::shared_ptr<Handler> handler;
inline void requestRoutes(App& app)
diff --git a/include/webroutes.hpp b/include/webroutes.hpp
index 757a272d23..ec1bb23959 100644
--- a/include/webroutes.hpp
+++ b/include/webroutes.hpp
@@ -6,6 +6,7 @@ namespace crow
namespace webroutes
{
+// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
static boost::container::flat_set<std::string> routes;
} // namespace webroutes