Compilation fixes for old gcc compiler

This commit is contained in:
Luca Deri
2022-05-28 16:06:34 +02:00
parent 7e3d061428
commit 77dc884a4c
3 changed files with 182 additions and 172 deletions
+7 -6
View File
@@ -364,7 +364,7 @@ flowGetBDMeanandVariance(struct ndpi_flow_info* flow) {
if (!flow->bidirectional) { if (!flow->bidirectional) {
array = last_entropy->src2dst_byte_count; array = last_entropy->src2dst_byte_count;
num_bytes = last_entropy->src2dst_l4_bytes; num_bytes = last_entropy->src2dst_l4_bytes;
for (i=0; i<256; i++) { for(i=0; i<256; i++) {
tmp[i] = last_entropy->src2dst_byte_count[i]; tmp[i] = last_entropy->src2dst_byte_count[i];
} }
@@ -378,7 +378,7 @@ flowGetBDMeanandVariance(struct ndpi_flow_info* flow) {
} }
} }
} else { } else {
for (i=0; i<256; i++) { for(i=0; i<256; i++) {
tmp[i] = last_entropy->src2dst_byte_count[i] + last_entropy->dst2src_byte_count[i]; tmp[i] = last_entropy->src2dst_byte_count[i] + last_entropy->dst2src_byte_count[i];
} }
array = tmp; array = tmp;
@@ -1640,7 +1640,9 @@ static void printFlowSerialized(u_int16_t thread_id,
ndpi_serialize_start_of_list(serializer, "risks"); ndpi_serialize_start_of_list(serializer, "risks");
if (flow->risk != NDPI_NO_RISK) if (flow->risk != NDPI_NO_RISK)
{ {
for (u_int32_t i = 0; i < NDPI_MAX_RISK; ++i) u_int32_t i;
for(i = 0; i < NDPI_MAX_RISK; ++i)
{ {
if (NDPI_ISSET_BIT(flow->risk, i) != 0) if (NDPI_ISSET_BIT(flow->risk, i) != 0)
{ {
@@ -3260,9 +3262,8 @@ static void printFlowsStats() {
unsigned int i; unsigned int i;
num_flows = 0; num_flows = 0;
for (thread_id = 0; thread_id < num_threads; thread_id++) { for(thread_id = 0; thread_id < num_threads; thread_id++) {
for (i = 0; i < NUM_ROOTS; i++) for(i = 0; i < NUM_ROOTS; i++) {
{
ndpi_twalk(ndpi_thread_info[thread_id].workflow->ndpi_flows_root[i], ndpi_twalk(ndpi_thread_info[thread_id].workflow->ndpi_flows_root[i],
node_print_known_proto_walker, &thread_id); node_print_known_proto_walker, &thread_id);
ndpi_twalk(ndpi_thread_info[thread_id].workflow->ndpi_flows_root[i], ndpi_twalk(ndpi_thread_info[thread_id].workflow->ndpi_flows_root[i],
+9 -5
View File
@@ -2260,8 +2260,9 @@ int ndpi_isset_risk(struct ndpi_detection_module_struct *ndpi_str,
int ndpi_is_printable_string(char * const str, size_t len) { int ndpi_is_printable_string(char * const str, size_t len) {
int retval = 1; int retval = 1;
size_t i;
for (size_t i = 0; i < len; ++i) { for(i = 0; i < len; ++i) {
if(ndpi_isprint(str[i]) == 0) { if(ndpi_isprint(str[i]) == 0) {
str[i] = '?'; str[i] = '?';
retval = 0; retval = 0;
@@ -2274,7 +2275,9 @@ int ndpi_is_printable_string(char * const str, size_t len) {
/* ******************************************************************** */ /* ******************************************************************** */
int ndpi_is_valid_hostname(char * const str, size_t len) { int ndpi_is_valid_hostname(char * const str, size_t len) {
for (size_t i = 0; i < len; ++i) { size_t i;
for(i = 0; i < len; ++i) {
if((str[i] == '.') if((str[i] == '.')
|| (str[i] == '-') || (str[i] == '-')
|| (str[i] == '_') || (str[i] == '_')
@@ -2297,14 +2300,15 @@ int ndpi_is_valid_hostname(char * const str, size_t len) {
float ndpi_entropy(u_int8_t const * const buf, size_t len) { float ndpi_entropy(u_int8_t const * const buf, size_t len) {
float entropy = 0.0f; float entropy = 0.0f;
u_int32_t byte_counters[256]; u_int32_t byte_counters[256];
size_t i;
memset(byte_counters, 0, sizeof(byte_counters)); memset(byte_counters, 0, sizeof(byte_counters));
for (size_t i = 0; i < len; ++i) { for(i = 0; i < len; ++i) {
byte_counters[buf[i]]++; byte_counters[buf[i]]++;
} }
for (size_t i = 0; i < sizeof(byte_counters) / sizeof(byte_counters[0]); ++i) { for(i = 0; i < sizeof(byte_counters) / sizeof(byte_counters[0]); ++i) {
if(byte_counters[i] == 0) { if(byte_counters[i] == 0) {
continue; continue;
} }
@@ -2330,7 +2334,7 @@ u_int16_t ndpi_calculate_icmp4_checksum(const u_int8_t * buf, size_t len) {
* The next two bytes is the checksum, which we want to ignore. * The next two bytes is the checksum, which we want to ignore.
*/ */
for (; len > 1; len -= 2) { for(; len > 1; len -= 2) {
checksum += get_n16bit(buf); checksum += get_n16bit(buf);
buf += 2; buf += 2;
} }
+166 -161
View File
File diff suppressed because it is too large Load Diff