mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
bifcl: Fix clang-tidy warnings
This commit is contained in:
parent
22d82edc74
commit
d3ac12da68
5 changed files with 21 additions and 11 deletions
|
@ -12,8 +12,15 @@ add_flex_bison_dependency(BIFScanner BIFParser)
|
|||
set(bifcl_SRCS ${BISON_BIFParser_INPUT} ${FLEX_BIFScanner_INPUT} ${BISON_BIFParser_OUTPUTS}
|
||||
${FLEX_BIFScanner_OUTPUTS} bif_arg.cc module_util.cc)
|
||||
|
||||
set(bifcl_bison_generated_files
|
||||
${CMAKE_CURRENT_BINARY_DIR}/bif_parse.cc ${CMAKE_CURRENT_BINARY_DIR}/bif_parse.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/bif_lex.cc)
|
||||
|
||||
set_source_files_properties(${bifcl_bison_generated_files} PROPERTIES SKIP_LINTING ON)
|
||||
|
||||
add_executable(bifcl ${bifcl_SRCS})
|
||||
target_include_directories(bifcl BEFORE PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||
zeek_target_add_linters(bifcl)
|
||||
|
||||
if (MSVC)
|
||||
target_compile_options(bifcl PUBLIC "/J") # Similar to -funsigned-char on other platforms
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// See the file "COPYING" in the main distribution directory for copyright.
|
||||
|
||||
#include "bif_arg.h"
|
||||
#include "include/bif_arg.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
|
@ -16,6 +16,7 @@ static struct {
|
|||
const char* constructor;
|
||||
const char* ctor_smart;
|
||||
} builtin_func_arg_type[] = {
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
|
||||
#define DEFINE_BIF_TYPE(id, bif_type, zeek_type, c_type, c_type_smart, accessor, accessor_smart, cast_smart, \
|
||||
constructor, ctor_smart) \
|
||||
{#id, bif_type, zeek_type, c_type, c_type_smart, accessor, accessor_smart, cast_smart, constructor, ctor_smart},
|
||||
|
|
|
@ -175,7 +175,7 @@ FILE* open_output_file(const char* surfix) {
|
|||
FILE* fp;
|
||||
|
||||
snprintf(fn, sizeof(fn), "%s.%s", input_filename, surfix);
|
||||
if ( (fp = fopen(fn, "w")) == NULL ) {
|
||||
if ( fp = fopen(fn, "w"); fp == nullptr ) {
|
||||
fprintf(stderr, "Error: cannot open file: %s\n", fn);
|
||||
err_exit();
|
||||
}
|
||||
|
@ -216,7 +216,7 @@ void init_alternative_mode() {
|
|||
fprintf(fp_func_register, "// %s\n\n", auto_gen_comment);
|
||||
|
||||
static char guard[1024];
|
||||
if ( getcwd(guard, sizeof(guard)) == NULL ) {
|
||||
if ( getcwd(guard, sizeof(guard)) == nullptr ) {
|
||||
fprintf(stderr, "Error: cannot get current working directory\n");
|
||||
err_exit();
|
||||
}
|
||||
|
@ -341,7 +341,7 @@ int main(int argc, char* argv[]) {
|
|||
input_filename = input_filename_with_path = argv[i];
|
||||
char* slash = strrchr(input_filename, '/');
|
||||
|
||||
if ( (fp_input = fopen(input_filename, "r")) == NULL ) {
|
||||
if ( fp_input = fopen(input_filename, "r"); fp_input == nullptr ) {
|
||||
fprintf(stderr, "Error: cannot open file: %s\n", input_filename);
|
||||
/* no output files open. can simply exit */
|
||||
exit(1);
|
||||
|
|
|
@ -164,6 +164,7 @@ static struct {
|
|||
const char* constructor;
|
||||
const char* ctor_smatr;
|
||||
} builtin_types[] = {
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
|
||||
#define DEFINE_BIF_TYPE(id, bif_type, zeek_type, c_type, c_type_smart, accessor, accessor_smart, cast_smart, constructor, ctor_smart) \
|
||||
{bif_type, zeek_type, c_type, c_type_smart, accessor, accessor_smart, cast_smart, constructor, ctor_smart},
|
||||
#include "bif_type.def"
|
||||
|
@ -238,14 +239,14 @@ static void print_event_c_body(FILE * fp) {
|
|||
|
||||
fprintf(fp, "\tzeek::event_mgr.Enqueue(%s, zeek::Args{\n", decl.c_fullname.c_str());
|
||||
|
||||
for ( int i = 0; i < (int)args.size(); ++i ) {
|
||||
for ( const auto& arg : args ) {
|
||||
fprintf(fp, "\t ");
|
||||
args[i]->PrintValConstructor(fp);
|
||||
arg->PrintValConstructor(fp);
|
||||
fprintf(fp, ",\n");
|
||||
|
||||
if ( args[i]->Type() == TYPE_CONNECTION ) {
|
||||
if ( arg->Type() == TYPE_CONNECTION ) {
|
||||
if ( connection_arg == nullptr )
|
||||
connection_arg = args[i];
|
||||
connection_arg = arg;
|
||||
else {
|
||||
// We are seeing two connection type arguments.
|
||||
yywarn(
|
||||
|
@ -453,7 +454,7 @@ enum_list: enum_list TOK_ID opt_ws ',' opt_ws
|
|||
|
||||
const_def: TOK_CONST opt_ws TOK_ID opt_ws ':' opt_ws TOK_ID opt_ws ';'
|
||||
{
|
||||
set_definition_type(CONST_DEF, 0);
|
||||
set_definition_type(CONST_DEF, nullptr);
|
||||
set_decl_name($3);
|
||||
int typeidx = get_type_index($7);
|
||||
char accessor[1024];
|
||||
|
@ -504,11 +505,11 @@ opt_attr_list:
|
|||
;
|
||||
|
||||
func_prefix: TOK_FUNCTION
|
||||
{ set_definition_type(FUNC_DEF, 0); }
|
||||
{ set_definition_type(FUNC_DEF, nullptr); }
|
||||
;
|
||||
|
||||
event_prefix: TOK_EVENT
|
||||
{ set_definition_type(EVENT_DEF, 0); }
|
||||
{ set_definition_type(EVENT_DEF, nullptr); }
|
||||
;
|
||||
|
||||
end_of_head: /* nothing */
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include <cstdio>
|
||||
|
||||
enum builtin_func_arg_type : uint8_t {
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
|
||||
#define DEFINE_BIF_TYPE(id, bif_type, bro_type, c_type, c_type_smart, accessor, accessor_smart, cast_smart, \
|
||||
constructor, ctor_smart) \
|
||||
id,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue