From d63812bd7356711e51aeefd6fbf5d97a4082faa6 Mon Sep 17 00:00:00 2001 From: Oron Peled Date: Sun, 21 Dec 2014 09:21:57 -0500 Subject: [PATCH] automake: migrated "--enable-dev-mode" * Fix small compile warnings (which are now errors): - hdlcgen.c - hdlcstress.c (remove return value which isn't checked) - patlooptest.c * Also added dev-mode to xpp with relevant compile fixes. Signed-off-by: Tzafrir Cohen --- Makefile.am | 12 +++++++++++- Makefile.legacy | 6 ------ configure.ac | 1 + hdlcgen.c | 2 +- hdlcstress.c | 3 +-- patlooptest.c | 3 +-- xpp/Makefile.am | 11 +++++++++++ xpp/astribank_hexload.c | 7 ++++++- xpp/hexfile.h | 6 +++++- 9 files changed, 37 insertions(+), 14 deletions(-) diff --git a/Makefile.am b/Makefile.am index 571653d..07b7614 100644 --- a/Makefile.am +++ b/Makefile.am @@ -5,7 +5,17 @@ LEGACY_MAKE = \ top_srcdir=$(top_srcdir) \ srcdir=$(srcdir) -CFLAGS = -g -Wall $(DAHDI_INCLUDE) +CFLAGS = -g -Wall -O2 $(DAHDI_INCLUDE) +if DAHDI_DEVMODE +CFLAGS += \ + -Werror \ + -Wunused \ + -Wundef \ + $(DAHDI_DECLARATION_AFTER_STATEMENT) \ + -Wmissing-format-attribute \ + -Wformat-security \ + #-Wformat=2 +endif SUBDIRS = xpp doc diff --git a/Makefile.legacy b/Makefile.legacy index 7bbd412..997f269 100644 --- a/Makefile.legacy +++ b/Makefile.legacy @@ -14,8 +14,6 @@ ifeq ($(strip $(foreach var,clean,$(findstring $(var),$(MAKECMDGOALS)))),) endif endif -OPTFLAGS=-O2 -CFLAGS+=-I. $(OPTFLAGS) -g -fPIC -Wall -DBUILDING_TONEZONE #-DTONEZONE_DRIVER ifneq (,$(findstring ppc,$(UNAME_M))) CFLAGS+=-fsigned-char endif @@ -23,10 +21,6 @@ ifneq (,$(findstring x86_64,$(UNAME_M))) CFLAGS+=-m64 endif -ifeq ($(DAHDI_DEVMODE),yes) - CFLAGS+=-Werror -Wunused -Wundef $(DAHDI_DECLARATION_AFTER_STATEMENT) -Wmissing-format-attribute -Wformat-security #-Wformat=2 -endif - ROOT_PREFIX= # extra cflags to build dependencies. Recursively expanded. diff --git a/configure.ac b/configure.ac index f476105..359f493 100644 --- a/configure.ac +++ b/configure.ac @@ -106,6 +106,7 @@ AC_ARG_ENABLE(dev-mode, *) AC_MSG_ERROR(bad value ${enableval} for --enable-dev-mode) ;; esac]) AC_SUBST(DAHDI_DEVMODE) +AM_CONDITIONAL([DAHDI_DEVMODE], [test "$DAHDI_DEVMODE" = 'yes']) AC_MSG_CHECKING(for -Wdeclaration-after-statement support) if $(${CC} -Wdeclaration-after-statement -S -o /dev/null -xc /dev/null > /dev/null 2>&1); then diff --git a/hdlcgen.c b/hdlcgen.c index 29811bb..3915925 100644 --- a/hdlcgen.c +++ b/hdlcgen.c @@ -40,7 +40,7 @@ #define RANDOM "/dev/urandom" /* Not genuinely random */ /* #define RANDOM "/dev/random" */ /* Quite genuinely random */ -int myread(int fd, char *buf, int len) +int myread(int fd, unsigned char *buf, int len) { int sofar; int res; diff --git a/hdlcstress.c b/hdlcstress.c index 6704f1f..a0cbde9 100644 --- a/hdlcstress.c +++ b/hdlcstress.c @@ -107,13 +107,12 @@ static struct fasthdlc_state fs; void send_packet(unsigned char *buf, int len) { - int res; int x; unsigned char outbuf[BLOCK_SIZE]; int pos=0; unsigned int fcs = PPP_INITFCS; if (hdlcmode) - res = write(fd, buf, len + 2); + write(fd, buf, len + 2); else { for (x=0;x optind +1) { timeout = strtoul(argv[optind+1], NULL, 10); } - - time_t start_time = 0; fd = channel_open(device, &bs); if (fd < 0) diff --git a/xpp/Makefile.am b/xpp/Makefile.am index f83fc43..fca3930 100644 --- a/xpp/Makefile.am +++ b/xpp/Makefile.am @@ -3,10 +3,21 @@ all-local: $(perl_checks) SUBDIRS = + # FIXME: try to improve code, so we can use $(PEDANTIC) #PEDANTIC = -ansi -pedantic -std=c99 GLOBAL_CFLAGS = -I$(srcdir) -I$(srcdir)/xtalk $(PEDANTIC) +if DAHDI_DEVMODE +GLOBAL_CFLAGS += \ + -Werror \ + -Wunused \ + -Wundef \ + -Wmissing-format-attribute \ + -Wformat-security \ + -Wformat=2 +endif + if PERL SUBDIRS += perl_modules diff --git a/xpp/astribank_hexload.c b/xpp/astribank_hexload.c index 643fe57..ffc158a 100644 --- a/xpp/astribank_hexload.c +++ b/xpp/astribank_hexload.c @@ -84,7 +84,12 @@ int handle_hexline(struct astribank_device *astribank, struct hexline *hexline) return 0; } -void print_parse_errors(int level, const char *msg, ...) + +#ifdef __GNUC__ +static void print_parse_errors(int level, const char *msg, ...) __attribute__((format(printf,2,3))); +#endif + +static void print_parse_errors(int level, const char *msg, ...) { va_list ap; diff --git a/xpp/hexfile.h b/xpp/hexfile.h index 27c71e7..33ff50d 100644 --- a/xpp/hexfile.h +++ b/xpp/hexfile.h @@ -72,7 +72,11 @@ struct hexdata { __BEGIN_DECLS -typedef void (*parse_hexfile_report_func_t)(int level, const char *msg, ...); +typedef void (*parse_hexfile_report_func_t)(int level, const char *msg, ...) +#ifdef __GNUC__ + __attribute__((format(printf,2,3))); +#endif + ; parse_hexfile_report_func_t parse_hexfile_set_reporting(parse_hexfile_report_func_t rf); void free_hexdata(struct hexdata *hexdata);