From patchwork Thu Jun 18 08:04:50 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Frysinger X-Patchwork-Id: 7230 Received: (qmail 85943 invoked by alias); 18 Jun 2015 08:04:57 -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 85927 invoked by uid 89); 18 Jun 2015 08:04:56 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 X-HELO: smtp.gentoo.org Received: from smtp.gentoo.org (HELO smtp.gentoo.org) (140.211.166.183) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 18 Jun 2015 08:04:55 +0000 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id C54FE340B27 for ; Thu, 18 Jun 2015 08:04:53 +0000 (UTC) From: Mike Frysinger To: gdb-patches@sourceware.org Subject: [PATCH] sim: callback: fix sentinel testing when walking maps Date: Thu, 18 Jun 2015 04:04:50 -0400 Message-Id: <1434614690-5852-1-git-send-email-vapier@gentoo.org> In-Reply-To: <1434561630-16170-1-git-send-email-vapier@gentoo.org> References: <1434561630-16170-1-git-send-email-vapier@gentoo.org> X-IsSubscribed: yes The new helpers for walking the maps tested the wrong value for exiting the for loop. This caused crashes when looking up entries that were not in the map. Committed. --- sim/common/ChangeLog | 5 +++++ sim/common/callback.c | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/sim/common/ChangeLog b/sim/common/ChangeLog index 59d92f4..afc1b3a 100644 --- a/sim/common/ChangeLog +++ b/sim/common/ChangeLog @@ -1,3 +1,8 @@ +2015-06-18 Mike Frysinger + + * callback.c (cb_target_map_entry, cb_host_map_entry): Change map to + m for sentinel testing. + 2015-06-17 Mike Frysinger * sim-syscall.c: Include errno.h and targ-vals.h. diff --git a/sim/common/callback.c b/sim/common/callback.c index 9b42536..486f182 100644 --- a/sim/common/callback.c +++ b/sim/common/callback.c @@ -803,7 +803,7 @@ cb_target_map_entry (const CB_TARGET_DEFS_MAP map[], int target_val) { const CB_TARGET_DEFS_MAP *m; - for (m = &map[0]; map->target_val != -1; ++m) + for (m = &map[0]; m->target_val != -1; ++m) if (m->target_val == target_val) return m; @@ -815,7 +815,7 @@ cb_host_map_entry (const CB_TARGET_DEFS_MAP map[], int host_val) { const CB_TARGET_DEFS_MAP *m; - for (m = &map[0]; map->host_val != -1; ++m) + for (m = &map[0]; m->host_val != -1; ++m) if (m->host_val == host_val) return m;