diff --git a/dependencies/nDPIsrvd.h b/dependencies/nDPIsrvd.h index 3b12304da..80da1ab12 100644 --- a/dependencies/nDPIsrvd.h +++ b/dependencies/nDPIsrvd.h @@ -686,7 +686,7 @@ static inline int nDPIsrvd_setup_address(struct nDPIsrvd_address * const address { address->raw.sa_family = AF_INET; address->size = sizeof(address->in); - address->in.sin_port = htons(atoi(last_colon + 1)); + address->in.sin_port = htons((uint16_t)atoi(last_colon + 1)); sock_addr = &address->in.sin_addr; if (len < 7) @@ -698,7 +698,7 @@ static inline int nDPIsrvd_setup_address(struct nDPIsrvd_address * const address { address->raw.sa_family = AF_INET6; address->size = sizeof(address->in6); - address->in6.sin6_port = htons(atoi(last_colon + 1)); + address->in6.sin6_port = htons((uint16_t)atoi(last_colon + 1)); sock_addr = &address->in6.sin6_addr; if (len < 2) @@ -803,7 +803,7 @@ static inline enum nDPIsrvd_conversion_return str_value_to_ull(char const * cons return CONVERSION_OK; } -static inline nDPIsrvd_hashkey nDPIsrvd_build_key(char const * str, int len) +static inline nDPIsrvd_hashkey nDPIsrvd_build_key(char const * str, size_t len) { uint32_t hash = nDPIsrvd_HASHKEY_SEED; uint32_t c; @@ -1099,7 +1099,7 @@ static inline struct nDPIsrvd_json_token * nDPIsrvd_find_token(struct nDPIsrvd_s static inline struct nDPIsrvd_json_token * nDPIsrvd_add_token(struct nDPIsrvd_socket * const sock, nDPIsrvd_hashkey hash_value, - int value_token_index) + size_t value_token_index) { struct nDPIsrvd_json_token * token = nDPIsrvd_find_token(sock, hash_value); @@ -1125,7 +1125,8 @@ static inline struct nDPIsrvd_json_token * nDPIsrvd_add_token(struct nDPIsrvd_so static inline int nDPIsrvd_walk_tokens( struct nDPIsrvd_socket * const sock, nDPIsrvd_hashkey h, size_t b, int count, uint8_t is_value, uint8_t depth) { - int i, j; + int i; + int j; jsmntok_t const * key; jsmntok_t const * const t = &sock->jsmn.tokens[b]; char const * const js = sock->buffer.json_message; @@ -1225,7 +1226,7 @@ static inline struct nDPIsrvd_instance * nDPIsrvd_get_instance(struct nDPIsrvd_s } static inline struct nDPIsrvd_thread_data * nDPIsrvd_get_thread_data( - struct nDPIsrvd_socket * const sock, + struct nDPIsrvd_socket const * const sock, struct nDPIsrvd_instance * const instance, struct nDPIsrvd_json_token const * const thread_id_token, struct nDPIsrvd_json_token const * const ts_usec_token) @@ -1241,7 +1242,7 @@ static inline struct nDPIsrvd_thread_data * nDPIsrvd_get_thread_data( { nDPIsrvd_ull thread_key; TOKEN_VALUE_TO_ULL(sock, thread_id_token, &thread_key); - thread_id = thread_key; + thread_id = (nDPIsrvd_hashkey)thread_key; } HASH_FIND_INT(instance->thread_data_table, &thread_id, thread_data); diff --git a/dependencies/nDPIsrvd.py b/dependencies/nDPIsrvd.py index 5ffa17e71..23bd86257 100644 --- a/dependencies/nDPIsrvd.py +++ b/dependencies/nDPIsrvd.py @@ -83,7 +83,6 @@ def setColorByString(string): global USE_COLORAMA if USE_COLORAMA is True: fg_color, bg_color = TermColor.getColorsByHash(string) - color_hash = TermColor.calcColorHash(string) return '{}{}{}{}{}'.format(Style.BRIGHT, fg_color, bg_color, string, Style.RESET_ALL) else: return '{}{}{}'.format(TermColor.BOLD, string, TermColor.END) diff --git a/examples/c-analysed/c-analysed.c b/examples/c-analysed/c-analysed.c index 36a99441d..2f6128e90 100644 --- a/examples/c-analysed/c-analysed.c +++ b/examples/c-analysed/c-analysed.c @@ -594,7 +594,8 @@ static int analysed_map_to_stat(char const * const token_str, struct global_map const * const map, size_t map_length) { - size_t i, null_i = map_length; + size_t i; + size_t null_i = map_length; for (i = 0; i < map_length; ++i) { @@ -621,7 +622,7 @@ static int analysed_map_to_stat(char const * const token_str, return 1; } -static int analysed_map_value_to_stat(struct nDPIsrvd_socket * const sock, +static int analysed_map_value_to_stat(struct nDPIsrvd_socket const * const sock, struct nDPIsrvd_json_token const * const token, struct global_map const * const map, size_t map_length) @@ -638,7 +639,7 @@ static int analysed_map_value_to_stat(struct nDPIsrvd_socket * const sock, return analysed_map_to_stat(value_str, value_length, map, map_length); } -static void analysed_unmap_flow_from_stat(struct flow_user_data * const flow_user_data) +static void analysed_unmap_flow_from_stat(struct flow_user_data const * const flow_user_data) { if (flow_user_data->is_ip4 != 0) { @@ -774,7 +775,7 @@ static ssize_t analysed_map_index(char const * const json_key, return unknown_key; } -static int analysed_map_flow_u8(struct nDPIsrvd_socket * const sock, +static int analysed_map_flow_u8(struct nDPIsrvd_socket const * const sock, struct nDPIsrvd_json_token const * const token, struct global_map const * const map, size_t map_length, @@ -1975,7 +1976,8 @@ static int mainloop(int epollfd, struct nDPIsrvd_socket * const sock) int main(int argc, char ** argv) { - int retval = 1, epollfd = -1; + int retval = 1; + int epollfd = -1; init_logging("nDPIsrvd-analysed"); diff --git a/examples/c-captured/c-captured.c b/examples/c-captured/c-captured.c index 0729d3f19..630d22256 100644 --- a/examples/c-captured/c-captured.c +++ b/examples/c-captured/c-captured.c @@ -197,7 +197,7 @@ static void decode_base64(pcap_dumper_t * const pd, static void packet_data_copy(void * dst, const void * src) { struct packet_data * const pd_dst = (struct packet_data *)dst; - struct packet_data const * const pd_src = (struct packet_data *)src; + struct packet_data const * const pd_src = (struct packet_data const *)src; *pd_dst = *pd_src; if (pd_src->base64_packet != NULL && pd_src->base64_packet_size > 0) { @@ -224,7 +224,7 @@ static void packet_data_dtor(void * elt) static void flow_packet_data_copy(void * dst, const void * src) { struct flow_packet_data * const pd_dst = (struct flow_packet_data *)dst; - struct flow_packet_data const * const pd_src = (struct flow_packet_data *)src; + struct flow_packet_data const * const pd_src = (struct flow_packet_data const *)src; *pd_dst = *pd_src; if (pd_src->base64_packet != NULL && pd_src->base64_packet_size > 0) { @@ -1175,7 +1175,7 @@ static int parse_options(int argc, char ** argv) break; case 'R': { - char * value = (optarg[0] == '~' ? optarg + 1 : optarg); + char const * const value = (optarg[0] == '~' ? optarg + 1 : optarg); nDPIsrvd_ull risk; if (perror_ull(str_value_to_ull(value, &risk), "process_risky") != CONVERSION_OK) { diff --git a/nDPId-test.c b/nDPId-test.c index 003376e57..e1d2bf9f5 100644 --- a/nDPId-test.c +++ b/nDPId-test.c @@ -1359,7 +1359,7 @@ static void usage(char const * const arg0) fprintf(stderr, "usage: %s [path-to-pcap-file] [optional-nDPId-config-file]\n", arg0); } -static int thread_wait_for_termination(pthread_t thread, time_t wait_time_secs, struct thread_return_value * const trv) +static int thread_wait_for_termination(pthread_t thread, time_t wait_time_secs, struct thread_return_value * trv) { #if !defined(__FreeBSD__) && !defined(__APPLE__) struct timespec ts;