diff --git a/.clang-tidy b/.clang-tidy index 314521eece..215b5a5e26 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,6 +1,7 @@ Checks: [-*, bugprone-*, performance-avoid-endl, + performance-enum-size, # Skipping these temporarily because they are very noisy -bugprone-narrowing-conversions, diff --git a/src/analyzer/protocol/http/HTTP.cc b/src/analyzer/protocol/http/HTTP.cc index 4aefbea232..7a72b9fd12 100644 --- a/src/analyzer/protocol/http/HTTP.cc +++ b/src/analyzer/protocol/http/HTTP.cc @@ -20,14 +20,14 @@ const bool DEBUG_http = false; // The EXPECT_*_NOTHING states are used to prevent further parsing. Used if a // message was interrupted. -enum HTTP_ExpectRequest { +enum HTTP_ExpectRequest : uint8_t { EXPECT_REQUEST_LINE, EXPECT_REQUEST_MESSAGE, EXPECT_REQUEST_TRAILER, EXPECT_REQUEST_NOTHING, }; -enum HTTP_ExpectReply { +enum HTTP_ExpectReply : uint8_t { EXPECT_REPLY_LINE, EXPECT_REPLY_MESSAGE, EXPECT_REPLY_TRAILER, diff --git a/src/analyzer/protocol/mime/MIME.cc b/src/analyzer/protocol/mime/MIME.cc index 5965f70242..e306bc874f 100644 --- a/src/analyzer/protocol/mime/MIME.cc +++ b/src/analyzer/protocol/mime/MIME.cc @@ -30,13 +30,13 @@ int mime_header_only = 0; int mime_decode_data = 1; int mime_submit_data = 1; -enum MIME_HEADER_FIELDS { +enum MIME_HEADER_FIELDS : uint8_t { MIME_CONTENT_TYPE, MIME_CONTENT_TRANSFER_ENCODING, MIME_FIELD_OTHER, }; -enum MIME_CONTENT_SUBTYPE { +enum MIME_CONTENT_SUBTYPE : uint8_t { CONTENT_SUBTYPE_MIXED, // for multipart CONTENT_SUBTYPE_ALTERNATIVE, // for multipart CONTENT_SUBTYPE_DIGEST, // for multipart @@ -50,7 +50,7 @@ enum MIME_CONTENT_SUBTYPE { CONTENT_SUBTYPE_OTHER, }; -enum MIME_CONTENT_ENCODING { +enum MIME_CONTENT_ENCODING : uint8_t { CONTENT_ENCODING_7BIT, CONTENT_ENCODING_8BIT, CONTENT_ENCODING_BINARY, @@ -59,7 +59,7 @@ enum MIME_CONTENT_ENCODING { CONTENT_ENCODING_OTHER, }; -enum MIME_BOUNDARY_DELIMITER { +enum MIME_BOUNDARY_DELIMITER : uint8_t { NOT_MULTIPART_BOUNDARY, MULTIPART_BOUNDARY, MULTIPART_CLOSING_BOUNDARY, diff --git a/src/cluster/backend/zeromq/ZeroMQ.cc b/src/cluster/backend/zeromq/ZeroMQ.cc index 077100c000..0479a8bf06 100644 --- a/src/cluster/backend/zeromq/ZeroMQ.cc +++ b/src/cluster/backend/zeromq/ZeroMQ.cc @@ -39,7 +39,7 @@ extern zeek::plugin::Zeek_Cluster_Backend_ZeroMQ::Plugin plugin; namespace cluster::zeromq { -enum class DebugFlag : zeek_uint_t { +enum class DebugFlag : uint8_t { NONE = 0, POLL = 1, THREAD = 2, @@ -50,9 +50,7 @@ enum class InprocTag : uint8_t { Terminate, }; -constexpr DebugFlag operator&(zeek_uint_t x, DebugFlag y) { - return static_cast(x & static_cast(y)); -} +constexpr DebugFlag operator&(uint8_t x, DebugFlag y) { return static_cast(x & static_cast(y)); } #define ZEROMQ_DEBUG(...) PLUGIN_DBG_LOG(zeek::plugin::Zeek_Cluster_Backend_ZeroMQ::plugin, __VA_ARGS__) diff --git a/src/input/ReaderBackend.cc b/src/input/ReaderBackend.cc index 664ffb10ab..4031c74f8b 100644 --- a/src/input/ReaderBackend.cc +++ b/src/input/ReaderBackend.cc @@ -49,7 +49,7 @@ private: class ReaderErrorMessage final : public threading::OutputMessage { public: - enum Type { INFO, WARNING, ERROR }; + enum Type : uint8_t { INFO, WARNING, ERROR }; ReaderErrorMessage(ReaderFrontend* reader, Type arg_type, const char* arg_msg) : threading::OutputMessage("ReaderErrorMessage", reader) { diff --git a/src/packet_analysis/protocol/icmp/ICMP.cc b/src/packet_analysis/protocol/icmp/ICMP.cc index d53361652b..5c40363acd 100644 --- a/src/packet_analysis/protocol/icmp/ICMP.cc +++ b/src/packet_analysis/protocol/icmp/ICMP.cc @@ -15,11 +15,6 @@ #include "zeek/packet_analysis/protocol/icmp/events.bif.h" #include "zeek/session/Manager.h" -enum ICMP_EndpointState { - ICMP_INACTIVE, // no packet seen - ICMP_ACTIVE, // packets seen -}; - using namespace zeek::packet_analysis::ICMP; using namespace zeek::packet_analysis::IP; diff --git a/src/packet_analysis/protocol/icmp/ICMPSessionAdapter.cc b/src/packet_analysis/protocol/icmp/ICMPSessionAdapter.cc index 3dbefd9c62..472df6a098 100644 --- a/src/packet_analysis/protocol/icmp/ICMPSessionAdapter.cc +++ b/src/packet_analysis/protocol/icmp/ICMPSessionAdapter.cc @@ -9,7 +9,7 @@ using namespace zeek::packet_analysis::ICMP; using namespace zeek::packet_analysis::IP; -enum ICMP_EndpointState { +enum ICMP_EndpointState : uint8_t { ICMP_INACTIVE, // no packet seen ICMP_ACTIVE, // packets seen }; diff --git a/src/packet_analysis/protocol/udp/UDPSessionAdapter.cc b/src/packet_analysis/protocol/udp/UDPSessionAdapter.cc index 932a06f2dc..8f0a1761d8 100644 --- a/src/packet_analysis/protocol/udp/UDPSessionAdapter.cc +++ b/src/packet_analysis/protocol/udp/UDPSessionAdapter.cc @@ -9,7 +9,7 @@ using namespace zeek::packet_analysis::UDP; using namespace zeek::packet_analysis::IP; -enum UDP_EndpointState { +enum UDP_EndpointState : uint8_t { UDP_INACTIVE, // no packet seen UDP_ACTIVE, // packets seen }; diff --git a/src/threading/MsgThread.cc b/src/threading/MsgThread.cc index 81764bbda8..144737ff4d 100644 --- a/src/threading/MsgThread.cc +++ b/src/threading/MsgThread.cc @@ -69,7 +69,7 @@ private: // A message from the child to be passed on to the Reporter. class ReporterMessage final : public OutputMessage { public: - enum Type { INFO, WARNING, ERROR, FATAL_ERROR, FATAL_ERROR_WITH_CORE, INTERNAL_WARNING, INTERNAL_ERROR }; + enum Type : uint8_t { INFO, WARNING, ERROR, FATAL_ERROR, FATAL_ERROR_WITH_CORE, INTERNAL_WARNING, INTERNAL_ERROR }; ReporterMessage(Type arg_type, MsgThread* thread, std::string_view arg_msg) : OutputMessage("ReporterMessage", thread) {