* [PATCH] Fix a bug in matching notifications.
@ 2013-12-10 14:12 Yao Qi
2013-12-10 14:48 ` Pedro Alves
0 siblings, 1 reply; 3+ messages in thread
From: Yao Qi @ 2013-12-10 14:12 UTC (permalink / raw)
To: gdb-patches
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Fix a bug in matching notifications.
2013-12-10 14:12 [PATCH] Fix a bug in matching notifications Yao Qi
@ 2013-12-10 14:48 ` Pedro Alves
2013-12-11 1:42 ` Yao Qi
0 siblings, 1 reply; 3+ messages in thread
From: Pedro Alves @ 2013-12-10 14:48 UTC (permalink / raw)
To: Yao Qi; +Cc: gdb-patches
On 12/10/2013 02:10 PM, Yao Qi wrote:
> 2013-12-10 Yao Qi <yao@codesourcery.com>
>
> * notif.c (handle_notif_ack): Return 0 if no notification
> matches.
OK, thanks.
> @@ -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;
(There's no real need to initialize 'i' here.)
> + struct notif_server *np;
>
> for (i = 0; i < ARRAY_SIZE (notifs); i++)
> {
--
Pedro Alves
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Fix a bug in matching notifications.
2013-12-10 14:48 ` Pedro Alves
@ 2013-12-11 1:42 ` Yao Qi
0 siblings, 0 replies; 3+ messages in thread
From: Yao Qi @ 2013-12-11 1:42 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches
On 12/10/2013 10:48 PM, Pedro Alves wrote:
> OK, thanks.
>
>> > @@ -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;
> (There's no real need to initialize 'i' here.)
>
Fixed in the patch below. Pushed.
--
Yao (é½å°§)
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index eb6f284..26d305e 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,3 +1,8 @@
+2013-12-11 Yao Qi <yao@codesourcery.com>
+
+ * notif.c (handle_notif_ack): Return 0 if no notification
+ matches.
+
2013-11-20 Doug Evans <dje@google.com>
* linux-low.c (linux_set_resume_request): Fix comment.
diff --git a/gdb/gdbserver/notif.c b/gdb/gdbserver/notif.c
index e27746e..6da2c5c 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;
+ 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))
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-12-11 1:42 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-10 14:12 [PATCH] Fix a bug in matching notifications Yao Qi
2013-12-10 14:48 ` Pedro Alves
2013-12-11 1:42 ` Yao Qi
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).