From 4a987308627b34b310b2bb5b46e7672a3e583852 Mon Sep 17 00:00:00 2001 From: Daniel Borkmann Date: Wed, 9 Jan 2013 21:16:38 +0100 Subject: [PATCH] make: add flags and fix some warnings Signed-off-by: Daniel Borkmann --- .gitignore | 3 +++ src/Makefile | 14 ++++++++++++-- src/bpf_hla_lexer.l | 2 +- src/bpf_hla_parser.y | 3 +++ src/ct_client.c | 4 ++-- src/ct_server.c | 2 +- src/curvetun.c | 2 +- src/flowtop.c | 2 +- src/ifpps.c | 4 ++-- src/trafgen.c | 4 ++++ src/trafgen_parser.y | 10 +++++----- 11 files changed, 35 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index 71b810e8..e19db4ee 100644 --- a/.gitignore +++ b/.gitignore @@ -27,6 +27,9 @@ src/build/ src/test/fuzzing/ +# Ignore if someone adapts Makefile +src/Makefile + # Other documentation ignores *.md *.ps diff --git a/src/Makefile b/src/Makefile index 7413f8b8..5c226cb5 100644 --- a/src/Makefile +++ b/src/Makefile @@ -73,7 +73,17 @@ WFLAGS += -Wstrict-prototypes WFLAGS += -Wundef WFLAGS += -Wimplicit-int -WFLAGS_EXTRA = +WFLAGS_EXTRA = -Wno-unused-result +WFLAGS_EXTRA += -Wmissing-parameter-type +WFLAGS_EXTRA += -Wunused-but-set-parameter +WFLAGS_EXTRA += -Wtype-limits +WFLAGS_EXTRA += -Wclobbered +WFLAGS_EXTRA += -Wmissing-field-initializers +WFLAGS_EXTRA += -Woverride-init +WFLAGS_EXTRA += -Wold-style-declaration +WFLAGS_EXTRA += -Wignored-qualifiers +WFLAGS_EXTRA += -Wempty-body +WFLAGS_EXTRA += -Wuninitialized CFLAGS += $(WFLAGS) -I. CPPFLAGS = @@ -240,7 +250,7 @@ astraceroute_install_custom: $(Q)$(call INST,conf/whois.conf,$(ETCDIRE)) $(Q)$(call INSTX,../scripts/astraceroute6,$(SBINDIR)) -$(TOOLS_MOST): WFLAGS += $(WFLAGS_EXTRA) +$(TOOLS): WFLAGS += $(WFLAGS_EXTRA) $(TOOLS): $(LD) $(ALL_LDFLAGS) -o $@/$@ $@/*.o $($@-libs) $(STRIP) $@/$@ diff --git a/src/bpf_hla_lexer.l b/src/bpf_hla_lexer.l index 812faf25..2c5bbabd 100644 --- a/src/bpf_hla_lexer.l +++ b/src/bpf_hla_lexer.l @@ -44,7 +44,7 @@ static const struct res_keywords keytab[] = { void bpf_hla_lex_init(void) { - int i; + size_t i; for (i = 0; i < array_size(keytab); ++i) bpf_symtab_insert(keytab[i].key, keytab[i].token); } diff --git a/src/bpf_hla_parser.y b/src/bpf_hla_parser.y index 77572b95..9f242510 100644 --- a/src/bpf_hla_parser.y +++ b/src/bpf_hla_parser.y @@ -81,6 +81,9 @@ int compile_hla_filter(char *file, int verbose, int debug) fpos_t pos; char file_tmp[128]; + /* XXX */ + verbose = verbose; + if (!strncmp("-", file, strlen("-"))) zzin = stdin; else diff --git a/src/ct_client.c b/src/ct_client.c index fb801328..178b6558 100644 --- a/src/ct_client.c +++ b/src/ct_client.c @@ -122,7 +122,7 @@ static void handler_udp_net_to_tun(int sfd, int dfd, struct curve25519_proto *p, cbuff += crypto_box_zerobytes; clen -= crypto_box_zerobytes; - if (write(dfd, cbuff, clen)); + if (write(dfd, cbuff, clen)) { ; } } return; @@ -208,7 +208,7 @@ static void handler_tcp_net_to_tun(int sfd, int dfd, struct curve25519_proto *p, cbuff += crypto_box_zerobytes; clen -= crypto_box_zerobytes; - if (write(dfd, cbuff, clen)); + if (write(dfd, cbuff, clen)) { ; } } return; diff --git a/src/ct_server.c b/src/ct_server.c index 3b1a1158..5e2f2d11 100644 --- a/src/ct_server.c +++ b/src/ct_server.c @@ -341,7 +341,7 @@ static void handler_tcp_notify_close(int fd) hdr.flags |= PROTO_FLAG_EXIT; hdr.payload = 0; - if (write(fd, &hdr, sizeof(hdr))); + if (write(fd, &hdr, sizeof(hdr))) { ; } } static int handler_tcp_net_to_tun(int fd, const struct worker_struct *ws, diff --git a/src/curvetun.c b/src/curvetun.c index 73dc17ec..e48c5894 100644 --- a/src/curvetun.c +++ b/src/curvetun.c @@ -590,7 +590,7 @@ int main(int argc, char **argv) enum working_mode wmode = MODE_UNKNOW; if (getuid() != geteuid()) - if (seteuid(getuid())); + if (seteuid(getuid())) { ; } home = fetch_home_dir(); diff --git a/src/flowtop.c b/src/flowtop.c index 65b8cdf5..d3e086ae 100644 --- a/src/flowtop.c +++ b/src/flowtop.c @@ -1119,7 +1119,7 @@ static void collector_destroy_geoip(void) GeoIP_delete(geo_city.gi6); } -static void inline collector_flush(struct nfct_handle *handle, uint8_t family) +static inline void collector_flush(struct nfct_handle *handle, uint8_t family) { nfct_query(handle, NFCT_Q_FLUSH, &family); } diff --git a/src/ifpps.c b/src/ifpps.c index 9870d03f..ee4f91a5 100644 --- a/src/ifpps.c +++ b/src/ifpps.c @@ -158,8 +158,8 @@ static int stats_proc_net_dev(const char *ifname, struct ifstat *stats) panic("Cannot open /proc/net/dev!\n"); /* Omit table header from procfs file */ - if (fgets(buff, sizeof(buff), fp)); - if (fgets(buff, sizeof(buff), fp)); + if (fgets(buff, sizeof(buff), fp)) { ; } + if (fgets(buff, sizeof(buff), fp)) { ; } memset(buff, 0, sizeof(buff)); diff --git a/src/trafgen.c b/src/trafgen.c index 0fcd2437..7cc38c5e 100644 --- a/src/trafgen.c +++ b/src/trafgen.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -680,6 +681,9 @@ int main(int argc, char **argv) unsigned long long tx_packets, tx_bytes; struct ctx ctx; + setfsuid(getuid()); + setfsgid(getgid()); + srand(time(NULL)); fmemset(&ctx, 0, sizeof(ctx)); ctx.cpus = get_number_cpus_online(); diff --git a/src/trafgen_parser.y b/src/trafgen_parser.y index efaed8be..bbd48cdd 100644 --- a/src/trafgen_parser.y +++ b/src/trafgen_parser.y @@ -115,7 +115,7 @@ static void set_byte(uint8_t val) static void set_fill(uint8_t val, size_t len) { - int i; + size_t i; struct packet *pkt = &packets[packet_last]; if (test_ignore()) @@ -129,7 +129,7 @@ static void set_fill(uint8_t val, size_t len) static void set_rnd(size_t len) { - int i; + size_t i; struct packet *pkt = &packets[packet_last]; if (test_ignore()) @@ -143,7 +143,7 @@ static void set_rnd(size_t len) static void set_seqinc(uint8_t start, size_t len, uint8_t stepping) { - int i; + size_t i; struct packet *pkt = &packets[packet_last]; if (test_ignore()) @@ -161,7 +161,7 @@ static void set_seqinc(uint8_t start, size_t len, uint8_t stepping) static void set_seqdec(uint8_t start, size_t len, uint8_t stepping) { - int i; + size_t i; struct packet *pkt = &packets[packet_last]; if (test_ignore()) @@ -401,7 +401,7 @@ static void dump_conf(void) void cleanup_packets(void) { - int i; + size_t i; for (i = 0; i < plen; ++i) { if (packets[i].len > 0) -- 2.11.4.GIT