From: Uwe Hermann Date: Sat, 11 Apr 2015 19:03:53 +0000 (+0200) Subject: Fix a compiler warning when -Wshadow is used. X-Git-Tag: libserialport-0.1.1~60 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=613c48f19198f53a8241114d89958c720fbc924a;p=libserialport.git Fix a compiler warning when -Wshadow is used. CC serialport.lo In file included from ../serialport.c:25:0: ../serialport.c: In function 'get_config': ../libserialport_internal.h:227:25: warning: declaration of 'ret' shadows a previous local [-Wshadow] #define TRY(x) do { int ret = x; if (ret != SP_OK) RETURN_CODEVAL(ret); } while (0) ^ ../serialport.c:1566:3: note: in expansion of macro 'TRY' TRY(get_baudrate(port->fd, &config->baudrate)); ^ ../serialport.c:1543:6: warning: shadowed declaration is here [-Wshadow] int ret = get_flow(port->fd, data); ^ Also, add -Wshadow to the list of default compiler options. --- diff --git a/configure.ac b/configure.ac index f01644b..b8589d0 100644 --- a/configure.ac +++ b/configure.ac @@ -39,7 +39,7 @@ m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) # Enable more compiler warnings. -CFLAGS="$CFLAGS -std=c99 -Wall -Wextra -pedantic -Wmissing-prototypes" +CFLAGS="$CFLAGS -std=c99 -Wall -Wextra -pedantic -Wmissing-prototypes -Wshadow" # Checks for programs. AC_PROG_CC diff --git a/libserialport_internal.h b/libserialport_internal.h index 6a8c877..6a682cb 100644 --- a/libserialport_internal.h +++ b/libserialport_internal.h @@ -224,7 +224,7 @@ extern void (*sp_debug_handler)(const char *format, ...); #define TRACE(fmt, ...) DEBUG_FMT("%s(" fmt ") called", __func__, __VA_ARGS__) #define TRACE_VOID() DEBUG_FMT("%s() called", __func__) -#define TRY(x) do { int ret = x; if (ret != SP_OK) RETURN_CODEVAL(ret); } while (0) +#define TRY(x) do { int retval = x; if (retval != SP_OK) RETURN_CODEVAL(retval); } while (0) SP_PRIV struct sp_port **list_append(struct sp_port **list, const char *portname);