mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Fix clang-tidy bugprone-macro-parentheses warnings in headers
This commit is contained in:
parent
d327d6388c
commit
13b7713889
10 changed files with 31 additions and 27 deletions
|
@ -232,10 +232,12 @@ public:
|
||||||
bool IsParen() const { return paren; }
|
bool IsParen() const { return paren; }
|
||||||
|
|
||||||
// These are used by script optimization for AST analysis.
|
// These are used by script optimization for AST analysis.
|
||||||
|
// NOLINTBEGIN(bugprone-macro-parentheses)
|
||||||
#define ZEEK_EXPR_ACCESSOR_DECLS(ctype) \
|
#define ZEEK_EXPR_ACCESSOR_DECLS(ctype) \
|
||||||
const ctype* As##ctype() const; \
|
const ctype* As##ctype() const; \
|
||||||
ctype* As##ctype(); \
|
ctype* As##ctype(); \
|
||||||
IntrusivePtr<ctype> As##ctype##Ptr();
|
IntrusivePtr<ctype> As##ctype##Ptr();
|
||||||
|
// NOLINTEND(bugprone-macro-parentheses)
|
||||||
|
|
||||||
ZEEK_EXPR_ACCESSOR_DECLS(AddToExpr)
|
ZEEK_EXPR_ACCESSOR_DECLS(AddToExpr)
|
||||||
ZEEK_EXPR_ACCESSOR_DECLS(AssignExpr)
|
ZEEK_EXPR_ACCESSOR_DECLS(AssignExpr)
|
||||||
|
|
|
@ -317,4 +317,4 @@ using name_list = PList<char>;
|
||||||
// Macro to visit each list element in turn.
|
// Macro to visit each list element in turn.
|
||||||
#define loop_over_list(list, iterator) \
|
#define loop_over_list(list, iterator) \
|
||||||
int iterator; \
|
int iterator; \
|
||||||
for ( iterator = 0; iterator < (list).length(); ++iterator )
|
for ( (iterator) = 0; (iterator) < (list).length(); ++(iterator) )
|
||||||
|
|
14
src/NFA.h
14
src/NFA.h
|
@ -5,16 +5,16 @@
|
||||||
#include "zeek/List.h"
|
#include "zeek/List.h"
|
||||||
#include "zeek/Obj.h"
|
#include "zeek/Obj.h"
|
||||||
|
|
||||||
#define NO_ACCEPT 0
|
constexpr int NO_ACCEPT = 0;
|
||||||
|
|
||||||
#define NO_UPPER_BOUND -1
|
constexpr int NO_UPPER_BOUND = -1;
|
||||||
|
|
||||||
#define SYM_BOL 256
|
constexpr int SYM_BOL = 256;
|
||||||
#define SYM_EOL 257
|
constexpr int SYM_EOL = 257;
|
||||||
#define NUM_SYM 258
|
constexpr int NUM_SYM = 258;
|
||||||
|
|
||||||
#define SYM_EPSILON 259
|
constexpr int SYM_EPSILON = 259;
|
||||||
#define SYM_CCL 260
|
constexpr int SYM_CCL = 260;
|
||||||
|
|
||||||
namespace zeek {
|
namespace zeek {
|
||||||
|
|
||||||
|
|
|
@ -95,7 +95,7 @@ public:
|
||||||
void BadTag(const char* msg, const char* t1 = nullptr, const char* t2 = nullptr) const;
|
void BadTag(const char* msg, const char* t1 = nullptr, const char* t2 = nullptr) const;
|
||||||
#define CHECK_TAG(t1, t2, text, tag_to_text_func) \
|
#define CHECK_TAG(t1, t2, text, tag_to_text_func) \
|
||||||
{ \
|
{ \
|
||||||
if ( t1 != t2 ) \
|
if ( (t1) != (t2) ) \
|
||||||
BadTag(text, tag_to_text_func(t1), tag_to_text_func(t2)); \
|
BadTag(text, tag_to_text_func(t1), tag_to_text_func(t2)); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -229,7 +229,7 @@ public:
|
||||||
static void hmac(const T& vlist, u_char key[ZEEK_MD5_DIGEST_LENGTH], u_char result[ZEEK_MD5_DIGEST_LENGTH]) {
|
static void hmac(const T& vlist, u_char key[ZEEK_MD5_DIGEST_LENGTH], u_char result[ZEEK_MD5_DIGEST_LENGTH]) {
|
||||||
digest(vlist, result);
|
digest(vlist, result);
|
||||||
|
|
||||||
for ( int i = 0; i < ZEEK_MD5_DIGEST_LENGTH; ++i )
|
for ( size_t i = 0; i < ZEEK_MD5_DIGEST_LENGTH; ++i )
|
||||||
result[i] ^= key[i];
|
result[i] ^= key[i];
|
||||||
|
|
||||||
detail::internal_md5(result, ZEEK_MD5_DIGEST_LENGTH, result);
|
detail::internal_md5(result, ZEEK_MD5_DIGEST_LENGTH, result);
|
||||||
|
|
|
@ -781,25 +781,26 @@ private:
|
||||||
/**
|
/**
|
||||||
* Internal convenience macro to iterate over the list of child analyzers.
|
* Internal convenience macro to iterate over the list of child analyzers.
|
||||||
*/
|
*/
|
||||||
#define LOOP_OVER_CHILDREN(var) for ( auto var = children.begin(); var != children.end(); ++var )
|
#define LOOP_OVER_CHILDREN(var) for ( auto(var) = children.begin(); (var) != children.end(); ++(var) )
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal convenience macro to iterate over the constant list of child
|
* Internal convenience macro to iterate over the constant list of child
|
||||||
* analyzers.
|
* analyzers.
|
||||||
*/
|
*/
|
||||||
#define LOOP_OVER_CONST_CHILDREN(var) for ( auto var = children.cbegin(); var != children.cend(); ++var )
|
#define LOOP_OVER_CONST_CHILDREN(var) for ( auto(var) = children.cbegin(); (var) != children.cend(); ++(var) )
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convenience macro to iterate over a given list of child analyzers.
|
* Convenience macro to iterate over a given list of child analyzers.
|
||||||
*/
|
*/
|
||||||
#define LOOP_OVER_GIVEN_CHILDREN(var, the_kids) for ( auto var = the_kids.begin(); var != the_kids.end(); ++var )
|
#define LOOP_OVER_GIVEN_CHILDREN(var, the_kids) \
|
||||||
|
for ( auto(var) = (the_kids).begin(); (var) != (the_kids).end(); ++(var) )
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convenience macro to iterate over a given constant list of child
|
* Convenience macro to iterate over a given constant list of child
|
||||||
* analyzers.
|
* analyzers.
|
||||||
*/
|
*/
|
||||||
#define LOOP_OVER_GIVEN_CONST_CHILDREN(var, the_kids) \
|
#define LOOP_OVER_GIVEN_CONST_CHILDREN(var, the_kids) \
|
||||||
for ( auto var = the_kids.cbegin(); var != the_kids.cend(); ++var )
|
for ( auto(var) = (the_kids).cbegin(); (var) != (the_kids).cend(); ++(var) )
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Support analyzer preprocess input before it reaches an analyzer's main
|
* Support analyzer preprocess input before it reaches an analyzer's main
|
||||||
|
|
|
@ -389,10 +389,11 @@ extern analyzer::Manager* analyzer_mgr;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
#define DBG_ANALYZER(conn, txt) \
|
#define DBG_ANALYZER(conn, txt) \
|
||||||
DBG_LOG(zeek::DBG_ANALYZER, "%s " txt, \
|
DBG_LOG(zeek::DBG_ANALYZER, "%s " txt, \
|
||||||
fmt_conn_id(conn->OrigAddr(), ntohs(conn->OrigPort()), conn->RespAddr(), ntohs(conn->RespPort())));
|
fmt_conn_id((conn)->OrigAddr(), ntohs((conn)->OrigPort()), (conn)->RespAddr(), \
|
||||||
|
ntohs((conn)->RespPort())));
|
||||||
#define DBG_ANALYZER_ARGS(conn, fmt, ...) \
|
#define DBG_ANALYZER_ARGS(conn, fmt, ...) \
|
||||||
DBG_LOG(zeek::DBG_ANALYZER, "%s " fmt, \
|
DBG_LOG(zeek::DBG_ANALYZER, "%s " fmt, \
|
||||||
fmt_conn_id(conn->OrigAddr(), ntohs(conn->OrigPort()), conn->RespAddr(), ntohs(conn->RespPort())), \
|
fmt_conn_id((conn)->OrigAddr(), ntohs((conn)->OrigPort()), (conn)->RespAddr(), ntohs((conn)->RespPort())), \
|
||||||
##__VA_ARGS__);
|
##__VA_ARGS__);
|
||||||
#else
|
#else
|
||||||
#define DBG_ANALYZER(conn, txt)
|
#define DBG_ANALYZER(conn, txt)
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
|
|
||||||
%extern{
|
%extern{
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#define FRAC_16 pow(2,-16)
|
#define FRAC_16 std::pow(2,-16)
|
||||||
#define FRAC_32 pow(2,-32)
|
#define FRAC_32 std::pow(2,-32)
|
||||||
// NTP defines the epoch from 1900, not 1970
|
// NTP defines the epoch from 1900, not 1970
|
||||||
#define EPOCH_OFFSET -2208988800
|
constexpr double EPOCH_OFFSET = -2208988800;
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%header{
|
%header{
|
||||||
|
|
14
src/digest.h
14
src/digest.h
|
@ -13,26 +13,26 @@
|
||||||
#include "zeek/util.h" // for util::bytetohex
|
#include "zeek/util.h" // for util::bytetohex
|
||||||
|
|
||||||
// Required buffer size for an MD5 digest.
|
// Required buffer size for an MD5 digest.
|
||||||
#define ZEEK_MD5_DIGEST_LENGTH 16
|
constexpr size_t ZEEK_MD5_DIGEST_LENGTH = 16;
|
||||||
|
|
||||||
// Required buffer size for an SHA1 digest.
|
// Required buffer size for an SHA1 digest.
|
||||||
#define ZEEK_SHA_DIGEST_LENGTH 20
|
constexpr size_t ZEEK_SHA_DIGEST_LENGTH = 20;
|
||||||
|
|
||||||
// Required buffer size for an SHA224 digest.
|
// Required buffer size for an SHA224 digest.
|
||||||
#define ZEEK_SHA224_DIGEST_LENGTH 28
|
constexpr size_t ZEEK_SHA224_DIGEST_LENGTH = 28;
|
||||||
|
|
||||||
// Required buffer size for an SHA256 digest.
|
// Required buffer size for an SHA256 digest.
|
||||||
#define ZEEK_SHA256_DIGEST_LENGTH 32
|
constexpr size_t ZEEK_SHA256_DIGEST_LENGTH = 32;
|
||||||
|
|
||||||
// Required buffer size for an SHA384 digest.
|
// Required buffer size for an SHA384 digest.
|
||||||
#define ZEEK_SHA384_DIGEST_LENGTH 48
|
constexpr size_t ZEEK_SHA384_DIGEST_LENGTH = 48;
|
||||||
|
|
||||||
// Required buffer size for an SHA512 digest.
|
// Required buffer size for an SHA512 digest.
|
||||||
#define ZEEK_SHA512_DIGEST_LENGTH 64
|
constexpr size_t ZEEK_SHA512_DIGEST_LENGTH = 64;
|
||||||
|
|
||||||
// Buffer size for a digest of any type in hex representation plus size for at
|
// Buffer size for a digest of any type in hex representation plus size for at
|
||||||
// least a null terminator.
|
// least a null terminator.
|
||||||
#define ZEEK_DIGEST_PRINT_LENGTH (ZEEK_SHA512_DIGEST_LENGTH * 2) + 1
|
constexpr size_t ZEEK_DIGEST_PRINT_LENGTH = (ZEEK_SHA512_DIGEST_LENGTH * 2) + 1;
|
||||||
|
|
||||||
namespace zeek::detail {
|
namespace zeek::detail {
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ class Stmt;
|
||||||
|
|
||||||
using ExprPtr = IntrusivePtr<Expr>;
|
using ExprPtr = IntrusivePtr<Expr>;
|
||||||
|
|
||||||
#define NO_DEF -1
|
constexpr int NO_DEF = -1;
|
||||||
|
|
||||||
// This class tracks a single region during which an identifier has
|
// This class tracks a single region during which an identifier has
|
||||||
// a consistent state of definition, meaning either it's (1) defined
|
// a consistent state of definition, meaning either it's (1) defined
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue