From patchwork Tue Feb 5 13:37:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 31312 Received: (qmail 45772 invoked by alias); 5 Feb 2019 13:37:50 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 45764 invoked by uid 89); 5 Feb 2019 13:37:50 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=HX-HELO:sk:gateway, Hx-spam-relays-external:cmsmtp, H*RU:cmsmtp, H*r:cmsmtp X-HELO: gateway33.websitewelcome.com Received: from gateway33.websitewelcome.com (HELO gateway33.websitewelcome.com) (192.185.146.21) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 05 Feb 2019 13:37:49 +0000 Received: from cm13.websitewelcome.com (cm13.websitewelcome.com [100.42.49.6]) by gateway33.websitewelcome.com (Postfix) with ESMTP id E4FE547C4337 for ; Tue, 5 Feb 2019 07:37:46 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id r0v4g5CLyYTGMr0v4gl5RA; Tue, 05 Feb 2019 07:37:46 -0600 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version :Content-Type:Content-Transfer-Encoding:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=PAbfyE/ocmZDvwtOQPrZAE9y7BYcwNXfaaUmeAjQ034=; b=p9JqM+cFPWcOd6gci74UwlgNwO xKSnBSwRhyf+wroahvlfwjVBIQYzwbsPnFMzuvo/jFMpuF9+uqzl2UD2K6jv7yOBxZqMLwvjlth5P nGFR48q3L1Ozan4t/9V1xZtQb; Received: from dhcp-guest.act-europe.fr ([194.98.77.127]:56376 helo=bapiya.act-europe.fr) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1gr0v4-000Voo-0b; Tue, 05 Feb 2019 07:37:46 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [FYI] Hoist assertion in target_stack::unpush Date: Tue, 5 Feb 2019 06:37:38 -0700 Message-Id: <20190205133738.9896-1-tom@tromey.com> 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. --- gdb/ChangeLog | 4 ++++ gdb/target.c | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) 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. */