aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStuart Reilly <rs576h@vyatta.att-mail.com>2019-07-12 15:59:11 +0100
committerStuart Reilly <rs576h@vyatta.att-mail.com>2019-07-12 16:01:22 +0100
commit8b1c68aed3228ff4e6b0c4e592c45c1426c51ace (patch)
tree1331e587f4efe94a76795a60c9ea9b99f0eba3f7
parent563215a05ee1d5a5ad5d72b749f8607f58e14c67 (diff)
Add compiler warnings and fix them
-rw-r--r--configure.seed4
-rw-r--r--example/ndpiReader.c11
-rw-r--r--example/ndpi_util.c2
-rw-r--r--src/lib/Makefile.in2
-rw-r--r--src/lib/ndpi_main.c1
-rw-r--r--src/lib/protocols/btlib.c49
-rw-r--r--src/lib/protocols/http.c4
-rw-r--r--src/lib/protocols/ookla.c1
8 files changed, 10 insertions, 64 deletions
diff --git a/configure.seed b/configure.seed
index 77d733f01..5d3ed0458 100644
--- a/configure.seed
+++ b/configure.seed
@@ -9,8 +9,12 @@ LT_INIT
AC_PROG_CC
AM_PROG_CC_C_O
AC_PROG_CXX
+AC_PROG_CC_STDC
+AC_LANG_WERROR
AX_PTHREAD
+CFLAGS+=" -Wall -Werror"
+
NDPI_VERSION_SHORT="@NDPI_VERSION_SHORT@"
NDPI_MAJOR="@NDPI_MAJOR@"
NDPI_MINOR="@NDPI_MINOR@"
diff --git a/example/ndpiReader.c b/example/ndpiReader.c
index 003737212..73dfdf051 100644
--- a/example/ndpiReader.c
+++ b/example/ndpiReader.c
@@ -2781,7 +2781,7 @@ void bpf_filter_pkt_peak_filter(json_object **jObj_bpfFilter,
int l;
if(port_array[0] != INIT_VAL)
- strncat(filter, " and not (src ", sizeof(" and not (src "));
+ strncat(filter, " and not (src ", sizeof(filter)/sizeof(char));
else
strcpy(filter, "not (src ");
@@ -2808,7 +2808,7 @@ void bpf_filter_pkt_peak_filter(json_object **jObj_bpfFilter,
int l;
if(port_array[0] != INIT_VAL || src_host_array[0] != NULL)
- strncat(filter, " and not (dst ", sizeof(" and not (dst "));
+ strncat(filter, " and not (dst ", sizeof(filter)/sizeof(char));
else
strcpy(filter, "not (dst ");
@@ -2955,7 +2955,6 @@ void bpf_filter_port_array_add(int filter_array[], int size, int port) {
float getAverage(struct json_object *jObj_stat, char *field){
json_object *field_stat;
json_bool res;
- float average;
float sum = 0;
int r;
int j = 0;
@@ -3003,11 +3002,11 @@ float getStdDeviation(struct json_object *jObj_stat, float average, char *field)
json_object *field_stat;
json_bool res;
float sum = 0;
- int j;
+ int j = 0;
int r;
if((r = strcmp(field, "top.scanner.stats")) == 0){
- for(j=0; j<json_object_array_length(jObj_stat); j++) {
+ for(; j<json_object_array_length(jObj_stat); j++) {
field_stat = json_object_array_get_idx(jObj_stat, j);
json_object *jObj_tot_flows_number;
@@ -3192,7 +3191,6 @@ static void produceBpfFilter(char *filePath) {
const char *filterPktDstHosts[48];
struct stat statbuf;
FILE *fp = NULL;
- char *fileName;
char _filterFilePath[1024];
json_object *jObj_bpfFilter;
void *fmap;
@@ -3288,7 +3286,6 @@ static void produceBpfFilter(char *filePath) {
}
- fileName = basename(filePath);
snprintf(_filterFilePath, sizeof(_filterFilePath), "%s.bpf", filePath);
if((fp = fopen(_filterFilePath,"w")) == NULL) {
diff --git a/example/ndpi_util.c b/example/ndpi_util.c
index b4d588c67..c055df317 100644
--- a/example/ndpi_util.c
+++ b/example/ndpi_util.c
@@ -732,7 +732,7 @@ struct ndpi_proto ndpi_workflow_process_packet(struct ndpi_workflow * workflow,
u_int16_t ip_offset = 0, ip_len;
u_int16_t frag_off = 0, vlan_id = 0;
u_int8_t proto = 0;
- u_int32_t label;
+ /*u_int32_t label;*/
/* counters */
u_int8_t vlan_packet = 0;
diff --git a/src/lib/Makefile.in b/src/lib/Makefile.in
index 1eb7abc59..45adb5eee 100644
--- a/src/lib/Makefile.in
+++ b/src/lib/Makefile.in
@@ -14,7 +14,7 @@ prefix = @prefix@
libdir = ${prefix}/lib
includedir = ${prefix}/include/ndpi
CC = @CC@
-CFLAGS += -fPIC -DPIC -I../include -Ithird_party/include -DNDPI_LIB_COMPILATION -O2 -g
+CFLAGS += -fPIC -DPIC -I../include -Ithird_party/include -DNDPI_LIB_COMPILATION -O2 -g @CFLAGS@
RANLIB = ranlib
OBJECTS = $(patsubst protocols/%.c, protocols/%.o, $(wildcard protocols/*.c)) $(patsubst third_party/src/%.c, third_party/src/%.o, $(wildcard third_party/src/*.c)) ndpi_main.o ndpi_utils.o
diff --git a/src/lib/ndpi_main.c b/src/lib/ndpi_main.c
index bb9b6de5a..325123476 100644
--- a/src/lib/ndpi_main.c
+++ b/src/lib/ndpi_main.c
@@ -491,7 +491,6 @@ void ndpi_init_protocol_match(struct ndpi_detection_module_struct *ndpi_mod,
ndpi_protocol_match *match) {
u_int16_t no_master[2] = { NDPI_PROTOCOL_NO_MASTER_PROTO, NDPI_PROTOCOL_NO_MASTER_PROTO };
ndpi_port_range ports_a[MAX_DEFAULT_PORTS], ports_b[MAX_DEFAULT_PORTS];
- static u_int16_t generic_id = NDPI_LAST_IMPLEMENTED_PROTOCOL;
if(ndpi_mod->proto_defaults[match->protocol_id].protoName == NULL) {
if(match->protocol_id == NDPI_PROTOCOL_GENERIC)
diff --git a/src/lib/protocols/btlib.c b/src/lib/protocols/btlib.c
index 71b4dff9a..c85acd54c 100644
--- a/src/lib/protocols/btlib.c
+++ b/src/lib/protocols/btlib.c
@@ -46,55 +46,6 @@ typedef unsigned long long int u_int64_t;
int bt_parse_debug = 0;
-static char *printXb(char *s,const u_int8_t *b,int l) {
- int i;
- for(i=0; i < l; i++)
- snprintf(&s[i*2],41,"%02x",b[i]);
- return s;
-}
-
-static char *print20b(char *s,const u_int8_t *b) {
- snprintf(s,41,"%08x%08x%08x%08x%08x",
- htonl(*(u_int32_t*)b),
- htonl(*(u_int32_t*)(b+4)),
- htonl(*(u_int32_t*)(b+8)),
- htonl(*(u_int32_t*)(b+12)),
- htonl(*(u_int32_t*)(b+16)));
- return s;
-}
-
-static char *print_id_ip_p(char *s, const struct bt_nodes_data *b) {
- u_int8_t *p = (u_int8_t*)b;
-
- print20b(s,b->id);
- snprintf(s+40,39," %d.%d.%d.%d:%u",
- p[20], p[21], p[22], p[23], htons(b->port));
- return s;
-}
-
-static char *print_ip_p(char *s, const struct bt_ipv4p *b,int np) {
- const u_int8_t *p = (const u_int8_t*)b;
-
- snprintf(s,39,!np ? "%d.%d.%d.%d:%u":"%d.%d.%d.%d",
- p[0], p[1], p[2], p[3], htons(b->port));
- return s;
-}
-
-static char *print_ip6_p(char *s, const struct bt_ipv6p *b,int np) {
- u_int16_t *p = (u_int16_t*)b;
-
- snprintf(s,79,!np ? "%x:%x:%x:%x:%x:%x:%x:%x.%u":"%x:%x:%x:%x:%x:%x:%x:%x",
- htons(p[0]), htons(p[1]), htons(p[2]), htons(p[3]),
- htons(p[4]), htons(p[5]), htons(p[6]), htons(p[7]),
- htons(b->port));
- return s;
-}
-
-static char *print_id_ip6_p(char *s,const struct bt_nodes6_data *b) {
- return print_ip6_p(s,(struct bt_ipv6p *)&b->ip,0);
-}
-
-
#if 0
void dump_bt_proto_struct(struct bt_parse_protocol *p) {
char b20h[128];
diff --git a/src/lib/protocols/http.c b/src/lib/protocols/http.c
index de2bb032e..1f5b88c7a 100644
--- a/src/lib/protocols/http.c
+++ b/src/lib/protocols/http.c
@@ -425,10 +425,6 @@ static struct l_string {
STATIC_STRING_L("REPORT ") };
static const char *http_fs = "CDGHOPR";
-static uint8_t non_ctrl(uint8_t c) {
- return c < 32 ? '.':c;
-}
-
static u_int16_t http_request_url_offset(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
{
struct ndpi_packet_struct *packet = &flow->packet;
diff --git a/src/lib/protocols/ookla.c b/src/lib/protocols/ookla.c
index 06d97e216..44746fbd3 100644
--- a/src/lib/protocols/ookla.c
+++ b/src/lib/protocols/ookla.c
@@ -27,7 +27,6 @@
void ndpi_search_ookla(struct ndpi_detection_module_struct* ndpi_struct, struct ndpi_flow_struct* flow) {
struct ndpi_packet_struct* packet = &flow->packet;
u_int32_t addr = 0;
- void *value;
NDPI_LOG_DBG(ndpi_struct, "Ookla detection\n");