[6/8] Avoid shadowing in fdwalk

Message ID 20180923040814.27941-7-tom@tromey.com
State New, archived
Headers

Commit Message

Tom Tromey Sept. 23, 2018, 4:08 a.m. UTC
  -Wshadow=local caught this buglet.  fdwalk redeclares "result" in the
inner scope, meaning that this function will always return 0, even on
error.

gdb/ChangeLog
2018-09-22  Tom Tromey  <tom@tromey.com>

	* common/filestuff.c (fdwalk): Remove inner declaration of
	"result".
---
 gdb/ChangeLog          | 5 +++++
 gdb/common/filestuff.c | 1 -
 2 files changed, 5 insertions(+), 1 deletion(-)
  

Comments

Kevin Buettner Oct. 12, 2018, 4:54 a.m. UTC | #1
On Sat, 22 Sep 2018 22:08:12 -0600
Tom Tromey <tom@tromey.com> wrote:

> -Wshadow=local caught this buglet.  fdwalk redeclares "result" in the
> inner scope, meaning that this function will always return 0, even on
> error.

Wow!

> gdb/ChangeLog
> 2018-09-22  Tom Tromey  <tom@tromey.com>
> 
> 	* common/filestuff.c (fdwalk): Remove inner declaration of
> 	"result".

This is okay.

Kevin
  

Patch

diff --git a/gdb/common/filestuff.c b/gdb/common/filestuff.c
index fa10165a7c..dfd86f9fbb 100644
--- a/gdb/common/filestuff.c
+++ b/gdb/common/filestuff.c
@@ -80,7 +80,6 @@  fdwalk (int (*func) (void *, int), void *arg)
 	{
 	  long fd;
 	  char *tail;
-	  int result;
 
 	  errno = 0;
 	  fd = strtol (entry->d_name, &tail, 10);