public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Clean up unusual code in mi-cmd-stack.c
@ 2023-01-25 15:06 Tom Tromey
  2023-01-25 18:14 ` Simon Marchi
  0 siblings, 1 reply; 2+ messages in thread
From: Tom Tromey @ 2023-01-25 15:06 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

I noticed some unusual code in mi-cmd-stack.c.  This code is a switch,
where one of the cases appears in the middle of another block.  It
seemed cleaner to me to have the earlier case just conditionally fall
through.
---
 gdb/mi/mi-cmd-stack.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/gdb/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c
index 00e61e04b67..4666808a9c9 100644
--- a/gdb/mi/mi-cmd-stack.c
+++ b/gdb/mi/mi-cmd-stack.c
@@ -571,7 +571,6 @@ list_args_or_locals (const frame_print_options &fp_opts,
   const struct block *block;
   struct symbol *sym;
   struct block_iterator iter;
-  struct type *type;
   const char *name_of_result;
   struct ui_out *uiout = current_uiout;
 
@@ -649,17 +648,20 @@ list_args_or_locals (const frame_print_options &fp_opts,
 	      switch (values)
 		{
 		case PRINT_SIMPLE_VALUES:
-		  type = check_typedef (sym2->type ());
-		  if (type->code () != TYPE_CODE_ARRAY
-		      && type->code () != TYPE_CODE_STRUCT
-		      && type->code () != TYPE_CODE_UNION)
-		    {
+		  {
+		    struct type *type = check_typedef (sym2->type ());
+		    if (type->code () == TYPE_CODE_ARRAY
+			|| type->code () == TYPE_CODE_STRUCT
+			|| type->code () == TYPE_CODE_UNION)
+		      break;
+		  }
+		  /* FALLTHROUGH */
+
 		case PRINT_ALL_VALUES:
 		  if (sym->is_argument ())
 		    read_frame_arg (fp_opts, sym2, fi, &arg, &entryarg);
 		  else
 		    read_frame_local (sym2, fi, &arg);
-		    }
 		  break;
 		}
 
-- 
2.38.1


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

* Re: [PATCH] Clean up unusual code in mi-cmd-stack.c
  2023-01-25 15:06 [PATCH] Clean up unusual code in mi-cmd-stack.c Tom Tromey
@ 2023-01-25 18:14 ` Simon Marchi
  0 siblings, 0 replies; 2+ messages in thread
From: Simon Marchi @ 2023-01-25 18:14 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches



On 1/25/23 10:06, Tom Tromey via Gdb-patches wrote:
> I noticed some unusual code in mi-cmd-stack.c.  This code is a switch,
> where one of the cases appears in the middle of another block.  It
> seemed cleaner to me to have the earlier case just conditionally fall
> through.

Thanks, that LGTM.  I would have been very confused if I had to deal
with that code.

Simon

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

end of thread, other threads:[~2023-01-25 18:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-25 15:06 [PATCH] Clean up unusual code in mi-cmd-stack.c Tom Tromey
2023-01-25 18:14 ` Simon Marchi

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).