public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [pushed] Trivially simplify rust_language::print_enum
@ 2023-02-09 19:16 Tom Tromey
  0 siblings, 0 replies; only message in thread
From: Tom Tromey @ 2023-02-09 19:16 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

rust_language::print_enum computes:

  int nfields = variant_type->num_fields ();

... but then does not reuse this in one spot.  This patch corrects the
oversight.
---
 gdb/rust-lang.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
index 6653f7a9c64..f2017f95211 100644
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
@@ -495,7 +495,7 @@ rust_language::print_enum (struct value *val, struct ui_file *stream,
     }
 
   bool first_field = true;
-  for (int j = 0; j < variant_type->num_fields (); j++)
+  for (int j = 0; j < nfields; j++)
     {
       if (!first_field)
 	gdb_puts (", ", stream);
-- 
2.39.1


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-02-09 19:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-09 19:16 [pushed] Trivially simplify rust_language::print_enum Tom Tromey

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