From 59b4e082a8f267ba1746de409d866231890988d0 Mon Sep 17 00:00:00 2001 From: Konstantinos Margaritis Date: Thu, 16 May 2024 15:58:02 +0300 Subject: [PATCH] add alternative macro without C casts to avoid Cppcheck warnings --- src/nfa/nfa_internal.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/nfa/nfa_internal.h b/src/nfa/nfa_internal.h index 8cc701b6..544867bc 100644 --- a/src/nfa/nfa_internal.h +++ b/src/nfa/nfa_internal.h @@ -1,5 +1,6 @@ /* * Copyright (c) 2015-2020, Intel Corporation + * Copyright (c) 2024, VectorCamp PC * Copyright (c) 2021, Arm Limited * * Redistribution and use in source and binary forms, with or without @@ -133,6 +134,7 @@ struct ALIGN_CL_DIRECTIVE NFA { /* Note: implementation (e.g. a LimEx) directly follows struct in memory */ } ; +#ifndef __cplusplus // Accessor macro for the implementation NFA: we do things this way to avoid // type-punning warnings. #define getImplNfa(nfa) \ @@ -140,6 +142,13 @@ struct ALIGN_CL_DIRECTIVE NFA { // Non-const version of the above, used at compile time. #define getMutableImplNfa(nfa) ((char *)(nfa) + sizeof(struct NFA)) +#else +// Same versions without C casts to avoid Cppcheck warnings +#define getImplNfa(nfa) \ + (reinterpret_cast(reinterpret_cast(nfa) + sizeof(struct NFA))) + +#define getMutableImplNfa(nfa) (reinterpret_cast(nfa) + sizeof(struct NFA)) +#endif static really_inline u32 nfaAcceptsEod(const struct NFA *nfa) { return nfa->flags & NFA_ACCEPTS_EOD;