/* Notification to GDB.
- Copyright (C) 1989, 1993-1995, 1997-2000, 2002-2012 Free Software
- Foundation, Inc.
+ Copyright (C) 1989-2018 Free Software Foundation, Inc.
This file is part of GDB.
# 3 is done by function 'handle_notif_ack'. */
+#include "server.h"
#include "notif.h"
static struct notif_server *notifs[] =
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 (startswith (own_buf, ack_name)
+ && 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))
= QUEUE_deque (notif_event_p, np->queue);
if (remote_debug)
- fprintf (stderr, "%s: acking %d\n", np->ack_name,
- QUEUE_length (notif_event_p, np->queue));
+ debug_printf ("%s: acking %d\n", np->ack_name,
+ QUEUE_length (notif_event_p, np->queue));
xfree (head);
}
QUEUE_enque (notif_event_p, notif->queue, event);
if (remote_debug)
- fprintf (stderr, "pending events: %s %d\n", notif->notif_name,
- QUEUE_length (notif_event_p, notif->queue));
+ debug_printf ("pending events: %s %d\n", notif->notif_name,
+ QUEUE_length (notif_event_p, notif->queue));
}