public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [RFA] fix shadowed function parm in d-valprint.c
@ 2011-02-27  0:24 Michael Snyder
  2011-02-27 16:45 ` Pedro Alves
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Snyder @ 2011-02-27  0:24 UTC (permalink / raw)
  To: gdb-patches; +Cc: Joel Brobecker, Pedro Alves, tromey

[-- Attachment #1: Type: text/plain, Size: 209 bytes --]

OK, this change does not change the semantics of the code, but
I can't be sure that they're not already wrong because of the
confusion between the function parm and the local variable.

What do you guys say?


[-- Attachment #2: shadow7.txt --]
[-- Type: text/plain, Size: 1319 bytes --]

2011-02-26  Michael Snyder  <msnyder@vmware.com>

	* d-valprint.c (dynamic_array_type): Avoid shadowing a function
	param with a local variable of the same name.

Index: d-valprint.c
===================================================================
RCS file: /cvs/src/src/gdb/d-valprint.c,v
retrieving revision 1.5
diff -u -p -u -p -r1.5 d-valprint.c
--- d-valprint.c	24 Jan 2011 18:54:15 -0000	1.5
+++ d-valprint.c	27 Feb 2011 00:08:09 -0000
@@ -45,7 +45,7 @@ dynamic_array_type (struct type *type, c
       struct type *elttype;
       struct type *true_type;
       struct type *ptr_type;
-      struct value *val;
+      struct value *ival;
       int length;
 
       length = unpack_field_as_long (type, valaddr + embedded_offset, 0);
@@ -58,12 +58,12 @@ dynamic_array_type (struct type *type, c
       true_type = check_typedef (elttype);
 
       true_type = lookup_array_range_type (true_type, 0, length - 1);
-      val = value_at (true_type, addr);
+      ival = value_at (true_type, addr);
 
       return d_val_print (true_type,
-			  value_contents_for_printing (val),
-			  value_embedded_offset (val), addr,
-			  stream, recurse + 1, val, options);
+			  value_contents_for_printing (ival),
+			  value_embedded_offset (ival), addr,
+			  stream, recurse + 1, ival, options);
     }
   return -1;
 }

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RFA] fix shadowed function parm in d-valprint.c
  2011-02-27  0:24 [RFA] fix shadowed function parm in d-valprint.c Michael Snyder
@ 2011-02-27 16:45 ` Pedro Alves
  2011-02-27 21:27   ` Michael Snyder
  0 siblings, 1 reply; 3+ messages in thread
From: Pedro Alves @ 2011-02-27 16:45 UTC (permalink / raw)
  To: Michael Snyder; +Cc: gdb-patches, Joel Brobecker, tromey

On Sunday 27 February 2011 00:11:47, Michael Snyder wrote:
> OK, this change does not change the semantics of the code, but
> I can't be sure that they're not already wrong because of the
> confusion between the function parm and the local variable.
> 
> What do you guys say?

Looks right to me.

-- 
Pedro Alves

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RFA] fix shadowed function parm in d-valprint.c
  2011-02-27 16:45 ` Pedro Alves
@ 2011-02-27 21:27   ` Michael Snyder
  0 siblings, 0 replies; 3+ messages in thread
From: Michael Snyder @ 2011-02-27 21:27 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches, Joel Brobecker, tromey

Pedro Alves wrote:
> On Sunday 27 February 2011 00:11:47, Michael Snyder wrote:
>> OK, this change does not change the semantics of the code, but
>> I can't be sure that they're not already wrong because of the
>> confusion between the function parm and the local variable.
>>
>> What do you guys say?
> 
> Looks right to me.
> 

OK, committed.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-02-27 21:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-27  0:24 [RFA] fix shadowed function parm in d-valprint.c Michael Snyder
2011-02-27 16:45 ` Pedro Alves
2011-02-27 21:27   ` Michael Snyder

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).