From d79648b4dc29d4c344b26ccb1440511e45c0b82a Mon Sep 17 00:00:00 2001 From: liuwentan Date: Fri, 21 Apr 2023 11:18:30 +0800 Subject: [PATCH] delete useless code --- src/inc_internal/maat_rule.h | 4 ++-- src/maat_bool_plugin.c | 6 ------ src/maat_compile.c | 20 ++++++++------------ src/maat_ex_data.c | 2 +- src/maat_fqdn_plugin.c | 6 ------ src/maat_ip_plugin.c | 6 ------ 6 files changed, 11 insertions(+), 33 deletions(-) diff --git a/src/inc_internal/maat_rule.h b/src/inc_internal/maat_rule.h index 691e043..f441da6 100644 --- a/src/inc_internal/maat_rule.h +++ b/src/inc_internal/maat_rule.h @@ -78,12 +78,12 @@ struct maat_item { struct compile_rule { long long magic_num; long long compile_id; - char table_name[NAME_MAX]; char *table_line; size_t table_line_len; - int declared_clause_num; struct compile_schema *ref_schema; void **ex_data; + int declared_clause_num; + char table_name[NAME_MAX]; }; struct group2group_rule { diff --git a/src/maat_bool_plugin.c b/src/maat_bool_plugin.c index 7692a47..abb5be0 100644 --- a/src/maat_bool_plugin.c +++ b/src/maat_bool_plugin.c @@ -27,9 +27,6 @@ struct bool_plugin_schema { int table_id; struct table_manager *ref_tbl_mgr; struct log_handle *logger; - - unsigned long long update_err_cnt; - unsigned long long unmatch_tag_cnt; }; struct bool_plugin_runtime { @@ -270,7 +267,6 @@ int bool_plugin_accept_tag_match(struct bool_plugin_schema *schema, const char * log_error(logger, MODULE_BOOL_PLUGIN, "[%s:%d] bool_plugin table(table_id:%d) has no rule_tag, line:%s", __FUNCTION__, __LINE__, schema->table_id, line); - schema->update_err_cnt++; return TAG_MATCH_ERR; } @@ -283,12 +279,10 @@ int bool_plugin_accept_tag_match(struct bool_plugin_schema *schema, const char * log_error(logger, MODULE_BOOL_PLUGIN, "[%s:%d] bool_plugin table(table_id:%d) has invalid tag format, line:%s", __FUNCTION__, __LINE__, schema->table_id, line); - schema->update_err_cnt++; return TAG_MATCH_ERR; } if (TAG_MATCH_UNMATCHED == ret) { - schema->unmatch_tag_cnt++; return TAG_MATCH_UNMATCHED; } } diff --git a/src/maat_compile.c b/src/maat_compile.c index 29c0598..98a40d8 100644 --- a/src/maat_compile.c +++ b/src/maat_compile.c @@ -31,15 +31,12 @@ struct compile_schema { int compile_id_column; int rule_tag_column; int declared_clause_num_column; - int table_id; //ugly - char table_name[NAME_MAX]; int set_flag; struct ex_data_schema ex_schema; struct table_manager *ref_tbl_mgr; struct log_handle *logger; - - unsigned long long update_err_cnt; - unsigned long long unmatch_tag_cnt; + int table_id; //ugly + char table_name[NAME_MAX]; }; struct group2compile_schema { @@ -475,7 +472,6 @@ int compile_accept_tag_match(struct compile_schema *schema, const char *line, log_error(logger, MODULE_COMPILE, "[%s:%d] compile table:%s has no rule_tag in line:%s", __FUNCTION__, __LINE__, table_name, line); - schema->update_err_cnt++; return TAG_MATCH_ERR; } @@ -488,12 +484,10 @@ int compile_accept_tag_match(struct compile_schema *schema, const char *line, log_error(logger, MODULE_COMPILE, "[%s:%d] compile table:%s has invalid tag format in line:%s", __FUNCTION__, __LINE__, table_name, line); - schema->update_err_cnt++; return TAG_MATCH_ERR; } if (TAG_MATCH_UNMATCHED == ret) { - schema->unmatch_tag_cnt++; return TAG_MATCH_UNMATCHED; } } @@ -988,7 +982,8 @@ size_t maat_compile_bool_matcher_match(struct compile_runtime *compile_rt, int i { size_t ud_result_cnt = 0; struct maat_compile *compile = NULL; - struct bool_expr_match *expr_match = compile_rt->expr_match_buff + compile_state->thread_id * MAX_SCANNER_HIT_COMPILE_NUM; + struct bool_expr_match *expr_match = compile_rt->expr_match_buff + + (compile_state->thread_id * MAX_SCANNER_HIT_COMPILE_NUM); assert(compile_state->thread_id >= 0); if (0 == compile_state->compile_rt_version) { @@ -1004,13 +999,14 @@ size_t maat_compile_bool_matcher_match(struct compile_runtime *compile_rt, int i //TODO:mytest need to delete #if 0 unsigned long long *p = utarray_eltptr(compile_state->all_hit_clauses, 0); - for (p = (unsigned long long *)utarray_front(compile_state->all_hit_clauses); p != NULL; p = (unsigned long long *)utarray_next(compile_state->all_hit_clauses, p)) - { + for (p = (unsigned long long *)utarray_front(compile_state->all_hit_clauses); p != NULL; + p = (unsigned long long *)utarray_next(compile_state->all_hit_clauses, p)) { printf("before bool_matcher_match compile_rt:%p compile_state clause_id:%llu\n", compile_rt, *p); } #endif - int bool_match_ret = bool_matcher_match(compile_rt->bm, (unsigned long long *)utarray_eltptr(compile_state->all_hit_clauses, 0), + int bool_match_ret = bool_matcher_match(compile_rt->bm, + (unsigned long long *)utarray_eltptr(compile_state->all_hit_clauses, 0), utarray_len(compile_state->all_hit_clauses), expr_match, MAX_SCANNER_HIT_COMPILE_NUM); for (int i = 0; i < bool_match_ret && ud_result_cnt < ud_array_size; i++) { diff --git a/src/maat_ex_data.c b/src/maat_ex_data.c index 0b6ab25..ce26e09 100644 --- a/src/maat_ex_data.c +++ b/src/maat_ex_data.c @@ -286,4 +286,4 @@ size_t ex_data_runtime_list_ex_container(struct ex_data_runtime *ex_data_rt, struct ex_container ***ex_container) { return rcu_hash_list(ex_data_rt->htable, (void ***)ex_container); -} +} \ No newline at end of file diff --git a/src/maat_fqdn_plugin.c b/src/maat_fqdn_plugin.c index 704b4ae..3ccd77c 100644 --- a/src/maat_fqdn_plugin.c +++ b/src/maat_fqdn_plugin.c @@ -28,9 +28,6 @@ struct fqdn_plugin_schema { int table_id; struct table_manager *ref_tbl_mgr; struct log_handle *logger; - - unsigned long long update_err_cnt; - unsigned long long unmatch_tag_cnt; }; struct fqdn_plugin_runtime { @@ -236,7 +233,6 @@ int fqdn_plugin_accept_tag_match(struct fqdn_plugin_schema *schema, const char * log_error(logger, MODULE_FQDN_PLUGIN, "[%s:%d] fqdn_plugin table(table_id:%d) has no rule_tag, line:%s", __FUNCTION__, __LINE__, schema->table_id, line); - schema->update_err_cnt++; return TAG_MATCH_ERR; } @@ -249,12 +245,10 @@ int fqdn_plugin_accept_tag_match(struct fqdn_plugin_schema *schema, const char * log_error(logger, MODULE_FQDN_PLUGIN, "[%s:%d] fqdn_plugin table(table_id:%d) has invalid tag format, line:%s", __FUNCTION__, __LINE__, schema->table_id, line); - schema->update_err_cnt++; return TAG_MATCH_ERR; } if (TAG_MATCH_UNMATCHED == ret) { - schema->unmatch_tag_cnt++; return TAG_MATCH_UNMATCHED; } } diff --git a/src/maat_ip_plugin.c b/src/maat_ip_plugin.c index 34e59be..8507785 100644 --- a/src/maat_ip_plugin.c +++ b/src/maat_ip_plugin.c @@ -32,9 +32,6 @@ struct ip_plugin_schema { int table_id; //ugly struct table_manager *ref_tbl_mgr; struct log_handle *logger; - - unsigned long long update_err_cnt; - unsigned long long unmatch_tag_cnt; }; struct ip_plugin_runtime { @@ -145,7 +142,6 @@ int ip_plugin_accept_tag_match(struct ip_plugin_schema *schema, const char *line log_error(logger, MODULE_IP_PLUGIN, "[%s:%d] ip_plugin table(table_id:%d) has no rule_tag, line:%s", __FUNCTION__, __LINE__, schema->table_id, line); - schema->update_err_cnt++; return TAG_MATCH_ERR; } @@ -158,12 +154,10 @@ int ip_plugin_accept_tag_match(struct ip_plugin_schema *schema, const char *line log_error(logger, MODULE_IP_PLUGIN, "[%s:%d] ip_plugin table(table_id:%d) has invalid tag format, line:%s", __FUNCTION__, __LINE__, schema->table_id, line); - schema->update_err_cnt++; return TAG_MATCH_ERR; } if (TAG_MATCH_UNMATCHED == ret) { - schema->unmatch_tag_cnt++; return TAG_MATCH_UNMATCHED; } }