From 84202f9c998c3f1bf0aa5d6457de7c9cad5f8500 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Fri, 18 Jul 2014 08:48:43 -0600 Subject: [PATCH] simplify target_is_pushed While working on target_is_pushed, I noticed that it is written in a strange way. The code currently keeps an extra indirection, where a simple linked list traversal is all that is needed. It seems likely this was done by copying and pasting other code. However, there is no reason to do this and the more obvious code is simpler to reason about. So, this patch change the implementation. 2014-07-29 Tom Tromey * target.c (target_is_pushed): Simplify. --- gdb/ChangeLog | 4 ++++ gdb/target.c | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 10b38cd388b..460547bdcce 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,7 @@ +2014-07-29 Tom Tromey + + * target.c (target_is_pushed): Simplify. + 2014-07-29 Joel Brobecker GDB 7.8 released. diff --git a/gdb/target.c b/gdb/target.c index d9b471b1350..46186bb019d 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -671,7 +671,7 @@ pop_all_targets (void) int target_is_pushed (struct target_ops *t) { - struct target_ops **cur; + struct target_ops *cur; /* Check magic number. If wrong, it probably means someone changed the struct definition, but not all the places that initialize one. */ @@ -684,8 +684,8 @@ target_is_pushed (struct target_ops *t) _("failed internal consistency check")); } - for (cur = &target_stack; (*cur) != NULL; cur = &(*cur)->beneath) - if (*cur == t) + for (cur = target_stack; cur != NULL; cur = cur->beneath) + if (cur == t) return 1; return 0; -- 2.30.2