Fix clang-tidy performance-enum-size warnings

This commit is contained in:
Tim Wojtulewicz 2025-04-25 13:42:16 -07:00
parent 11a1d8d506
commit f4c47d0357
9 changed files with 13 additions and 19 deletions

View file

@ -1,6 +1,7 @@
Checks: [-*,
bugprone-*,
performance-avoid-endl,
performance-enum-size,
# Skipping these temporarily because they are very noisy
-bugprone-narrowing-conversions,

View file

@ -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,

View file

@ -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,

View file

@ -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<DebugFlag>(x & static_cast<zeek_uint_t>(y));
}
constexpr DebugFlag operator&(uint8_t x, DebugFlag y) { return static_cast<DebugFlag>(x & static_cast<uint8_t>(y)); }
#define ZEROMQ_DEBUG(...) PLUGIN_DBG_LOG(zeek::plugin::Zeek_Cluster_Backend_ZeroMQ::plugin, __VA_ARGS__)

View file

@ -49,7 +49,7 @@ private:
class ReaderErrorMessage final : public threading::OutputMessage<ReaderFrontend> {
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<ReaderFrontend>("ReaderErrorMessage", reader) {

View file

@ -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;

View file

@ -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
};

View file

@ -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
};

View file

@ -69,7 +69,7 @@ private:
// A message from the child to be passed on to the Reporter.
class ReporterMessage final : public OutputMessage<MsgThread> {
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<MsgThread>("ReporterMessage", thread) {