This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix a bug in matching notifications.


Hi,
Due to copy-n-paste, the problem caused PR remote/15974 also exists
in gdbserver.  This patch fixes it in the same way.  Patch to fix
remote/15974 can be found:

  https://sourceware.org/ml/gdb-patches/2013-12/msg00014.html

gdb/gdbserver:

2013-12-10  Yao Qi  <yao@codesourcery.com>

	* notif.c (handle_notif_ack): Return 0 if no notification
	matches.
---
 gdb/gdbserver/notif.c |   15 +++++++++------
 1 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/gdb/gdbserver/notif.c b/gdb/gdbserver/notif.c
index e27746e..6520636 100644
--- a/gdb/gdbserver/notif.c
+++ b/gdb/gdbserver/notif.c
@@ -78,20 +78,23 @@ notif_write_event (struct notif_server *notif, char *own_buf)
 int
 handle_notif_ack (char *own_buf, int packet_len)
 {
-  int i = 0;
-  struct notif_server *np = NULL;
+  size_t i = 0;
+  struct notif_server *np;
 
   for (i = 0; i < ARRAY_SIZE (notifs); i++)
     {
-      np = notifs[i];
-      if (strncmp (own_buf, np->ack_name, strlen (np->ack_name)) == 0
-	  && packet_len == strlen (np->ack_name))
+      const char *ack_name = notifs[i]->ack_name;
+
+      if (strncmp (own_buf, ack_name, strlen (ack_name)) == 0
+	  && packet_len == strlen (ack_name))
 	break;
     }
 
-  if (np == NULL)
+  if (i == ARRAY_SIZE (notifs))
     return 0;
 
+  np = notifs[i];
+
   /* If we're waiting for GDB to acknowledge a pending event,
      consider that done.  */
   if (!QUEUE_is_empty (notif_event_p, np->queue))
-- 
1.7.7.6


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]