From 451b25cfadfc9fcaeb675012e4bc0bfb57fa73a6 Mon Sep 17 00:00:00 2001 From: Tim Wojtulewicz Date: Mon, 9 Jun 2025 19:03:51 -0700 Subject: [PATCH] Fix clang-tidy modernize-macro-to-enum warnings in headers --- cmake_templates/zeek-config.h.in | 3 +++ src/Val.h | 10 +++++----- src/analyzer/protocol/bittorrent/BitTorrentTracker.h | 2 +- src/analyzer/protocol/bittorrent/bittorrent.pac | 2 +- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/cmake_templates/zeek-config.h.in b/cmake_templates/zeek-config.h.in index 9130ecc66e..121e43c3e3 100644 --- a/cmake_templates/zeek-config.h.in +++ b/cmake_templates/zeek-config.h.in @@ -1,4 +1,5 @@ // See the file "COPYING" in the main distribution directory for copyright. +// NOLINTBEGIN(modernize-macro-to-enum) #pragma once @@ -306,3 +307,5 @@ /* compiled with Spicy support */ #cmakedefine HAVE_SPICY + +// NOLINTEND(modernize-macro-to-enum) diff --git a/src/Val.h b/src/Val.h index 4c5763107b..2a521f4179 100644 --- a/src/Val.h +++ b/src/Val.h @@ -18,12 +18,12 @@ // We have four different port name spaces: TCP, UDP, ICMP, and UNKNOWN. // We distinguish between them based on the bits specified in the *_PORT_MASK // entries specified below. -#define NUM_PORT_SPACES 4 -#define PORT_SPACE_MASK 0x30000 +constexpr int NUM_PORT_SPACES = 4; +constexpr uint32_t PORT_SPACE_MASK = 0x30000; -#define TCP_PORT_MASK 0x10000 -#define UDP_PORT_MASK 0x20000 -#define ICMP_PORT_MASK 0x30000 +constexpr uint32_t TCP_PORT_MASK = 0x10000; +constexpr uint32_t UDP_PORT_MASK = 0x20000; +constexpr uint32_t ICMP_PORT_MASK = 0x30000; namespace zeek { diff --git a/src/analyzer/protocol/bittorrent/BitTorrentTracker.h b/src/analyzer/protocol/bittorrent/BitTorrentTracker.h index f607672127..833a4dabc4 100644 --- a/src/analyzer/protocol/bittorrent/BitTorrentTracker.h +++ b/src/analyzer/protocol/bittorrent/BitTorrentTracker.h @@ -6,7 +6,7 @@ #include "zeek/analyzer/protocol/tcp/TCP.h" -#define BTTRACKER_BUF 2048 +constexpr uint32_t BTTRACKER_BUF = 2048; namespace zeek { diff --git a/src/analyzer/protocol/bittorrent/bittorrent.pac b/src/analyzer/protocol/bittorrent/bittorrent.pac index 3e9fad78e9..77f52b9649 100644 --- a/src/analyzer/protocol/bittorrent/bittorrent.pac +++ b/src/analyzer/protocol/bittorrent/bittorrent.pac @@ -4,7 +4,7 @@ %include zeek.pac %extern{ -#define MSGLEN_LIMIT 0x40000 +constexpr uint32_t MSGLEN_LIMIT = 0x40000; #include "zeek/analyzer/protocol/bittorrent/events.bif.h" %}