public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Mike Frysinger <vapier@gentoo.org>
To: gdb-patches@sourceware.org
Subject: [PATCH] sim: callback: fix sentinel testing when walking maps
Date: Thu, 18 Jun 2015 08:04:00 -0000	[thread overview]
Message-ID: <1434614690-5852-1-git-send-email-vapier@gentoo.org> (raw)
In-Reply-To: <1434561630-16170-1-git-send-email-vapier@gentoo.org>

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  <vapier@gentoo.org>
+
+	* callback.c (cb_target_map_entry, cb_host_map_entry): Change map to
+	m for sentinel testing.
+
 2015-06-17  Mike Frysinger  <vapier@gentoo.org>
 
 	* 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;
 
-- 
2.4.1

      parent reply	other threads:[~2015-06-18  8:04 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-17 17:20 [PATCH 1/3] sim: callback: add human readable strings for debugging to maps Mike Frysinger
2015-06-17 17:20 ` [PATCH 3/3] sim: syscall: add common sim_syscall helpers Mike Frysinger
2015-06-18  8:08   ` [PATCH] sim: syscall: simplify unknown syscall trace Mike Frysinger
2015-06-17 17:20 ` [PATCH 2/3] sim: syscall: unify memory helpers Mike Frysinger
2015-06-18  8:04 ` Mike Frysinger [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1434614690-5852-1-git-send-email-vapier@gentoo.org \
    --to=vapier@gentoo.org \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).