[PATCH/committed] sim: options: fix --help output

Message ID 20210502030934.22275-1-vapier@gentoo.org
State New
Headers show
Series
  • [PATCH/committed] sim: options: fix --help output
Related show

Commit Message

Mike Frysinger via Gdb-patches May 2, 2021, 3:09 a.m.
The hash table rewrite broke --help output due to subtle behavior:
calling dup_arg_p(NULL) will create & clear the table, not just
create it.  The --help output relies on this to clear the table
before it shows things.
---
 sim/common/ChangeLog     | 4 ++++
 sim/common/sim-options.c | 1 +
 2 files changed, 5 insertions(+)

-- 
2.31.1

Comments

Tom Tromey May 2, 2021, 8:42 p.m. | #1
Mike> The hash table rewrite broke --help output due to subtle behavior:
Mike> calling dup_arg_p(NULL) will create & clear the table, not just
Mike> create it.  The --help output relies on this to clear the table
Mike> before it shows things.

Oops, I'm sorry about that.  Thank you for fixing it.

Tom

Patch

diff --git a/sim/common/ChangeLog b/sim/common/ChangeLog
index 55d684bfeab8..7abaeb3a8166 100644
--- a/sim/common/ChangeLog
+++ b/sim/common/ChangeLog
@@ -1,3 +1,7 @@ 
+2021-05-01  Mike Frysinger  <vapier@gentoo.org>
+
+	* sim-options.c (dup_arg_p): Call htab_empty.
+
 2021-05-01  Mike Frysinger  <vapier@gentoo.org>
 
 	* dv-sockser.c (dv_sockser_install): Rename to ...
diff --git a/sim/common/sim-options.c b/sim/common/sim-options.c
index a6da8eccdefa..1522cac9379f 100644
--- a/sim/common/sim-options.c
+++ b/sim/common/sim-options.c
@@ -437,6 +437,7 @@  dup_arg_p (const char *arg)
 	arg_table = htab_create_alloc (10, htab_hash_string,
 				       compare_strings, NULL,
 				       xcalloc, free);
+      htab_empty (arg_table);
       return 0;
     }