From: Tom Tromey Date: Tue, 5 Feb 2019 11:59:11 +0000 (-0700) Subject: Hoist assertion in target_stack::unpush X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=1688cb2916e7bc46c92dd6f5ac2ba0da6c832274;p=binutils-gdb.git Hoist assertion in target_stack::unpush I noticed that target_stack::unpush first uses the target "t", then later asserts that it is non-NULL: strata stratum = t->stratum (); [...] gdb_assert (t != NULL); This is backwards, though, as the assertion must come first. gdb/ChangeLog 2019-02-05 Tom Tromey * target.c (target_stack::unpush): Move assertion earlier. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index b06398ab33f..0ce33f237e8 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,7 @@ +2019-02-05 Tom Tromey + + * target.c (target_stack::unpush): Move assertion earlier. + 2019-01-30 Tom Tromey PR python/23615: diff --git a/gdb/target.c b/gdb/target.c index c5502ce1791..c1ab07f7608 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -598,14 +598,14 @@ unpush_target (struct target_ops *t) bool target_stack::unpush (target_ops *t) { + gdb_assert (t != NULL); + strata stratum = t->stratum (); if (stratum == dummy_stratum) internal_error (__FILE__, __LINE__, _("Attempt to unpush the dummy target")); - gdb_assert (t != NULL); - /* Look for the specified target. Note that a target can only occur once in the target stack. */