binpac: Fix a large number of clang-tidy warnings

This commit is contained in:
Tim Wojtulewicz 2025-08-21 15:05:42 +00:00
parent 4dc546f8c8
commit 31b65f70da
48 changed files with 231 additions and 193 deletions

View file

@ -21,6 +21,7 @@ if (BUILD_STATIC_BINPAC)
target_compile_options(binpac_static PRIVATE "/J")
endif ()
set(BinPAC_LIBRARY binpac_static CACHE STRING "BinPAC library" FORCE)
zeek_target_add_linters(binpac_static)
else ()
add_library(binpac_lib SHARED)
target_sources(binpac_lib PRIVATE ${binpac_lib_SRCS})
@ -31,6 +32,7 @@ else ()
endif ()
install(TARGETS binpac_lib DESTINATION ${CMAKE_INSTALL_LIBDIR})
set(BinPAC_LIBRARY binpac_lib CACHE STRING "BinPAC library" FORCE)
zeek_target_add_linters(binpac_lib)
endif ()
if (ZEEK_ROOT_DIR)

View file

@ -1,8 +1,8 @@
// See the file "COPYING" in the main distribution directory for copyright.
#include <stdio.h>
#include <stdlib.h>
#include <string.h> // for memcpy
#include <cstdio>
#include <cstdlib>
#include <cstring> // for memcpy
#define binpac_regex_h
@ -82,7 +82,7 @@ void FlowBuffer::ResetLineState() {
case CR_OR_LF: state_ = CR_OR_LF_0; break;
case STRICT_CRLF: state_ = STRICT_CRLF_0; break;
case LINE_BREAKER: break; // Nothing to reset
default: BINPAC_ASSERT(0); break;
default: BINPAC_ASSERT(false); break;
}
}
@ -248,7 +248,7 @@ void FlowBuffer::MarkOrCopyLine() {
case CR_OR_LF: MarkOrCopyLine_CR_OR_LF(); break;
case STRICT_CRLF: MarkOrCopyLine_STRICT_CRLF(); break;
case LINE_BREAKER: MarkOrCopyLine_LINEBREAK(); break;
default: BINPAC_ASSERT(0); break;
default: BINPAC_ASSERT(false); break;
}
}

View file

@ -4,11 +4,11 @@
#include "binpac_bytestring.h"
#include <stdlib.h>
#include <cstdlib>
namespace binpac {
std::string std_string(bytestring const* s) { return std::string((const char*)s->begin(), (const char*)s->end()); }
std::string std_string(bytestring const* s) { return {(const char*)s->begin(), (const char*)s->end()}; }
int bytestring_to_int(bytestring const* s) { return atoi((const char*)s->begin()); }