From 613c48f19198f53a8241114d89958c720fbc924a Mon Sep 17 00:00:00 2001 From: Uwe Hermann Date: Sat, 11 Apr 2015 21:03:53 +0200 Subject: [PATCH] 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. --- configure.ac | 2 +- libserialport_internal.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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);