From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31737 invoked by alias); 11 Dec 2013 01:42:53 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 31724 invoked by uid 89); 11 Dec 2013 01:42:52 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=1.5 required=5.0 tests=AWL,BAYES_00,GARBLED_BODY autolearn=no version=3.3.2 X-HELO: relay1.mentorg.com Received: from Unknown (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 11 Dec 2013 01:42:52 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1VqYou-00023b-99 from Yao_Qi@mentor.com ; Tue, 10 Dec 2013 17:42:36 -0800 Received: from SVR-ORW-FEM-03.mgc.mentorg.com ([147.34.97.39]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Tue, 10 Dec 2013 17:42:36 -0800 Received: from qiyao.dyndns.org (147.34.91.1) by svr-orw-fem-03.mgc.mentorg.com (147.34.97.39) with Microsoft SMTP Server id 14.2.247.3; Tue, 10 Dec 2013 17:42:35 -0800 Message-ID: <52A7C2BB.90302@codesourcery.com> Date: Wed, 11 Dec 2013 01:42:00 -0000 From: Yao Qi User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: Pedro Alves CC: Subject: Re: [PATCH] Fix a bug in matching notifications. References: <1386684626-11415-1-git-send-email-yao@codesourcery.com> <52A729B1.1020408@redhat.com> In-Reply-To: <52A729B1.1020408@redhat.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-IsSubscribed: yes X-SW-Source: 2013-12/txt/msg00400.txt.bz2 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 + + * notif.c (handle_notif_ack): Return 0 if no notification + matches. + 2013-11-20 Doug Evans * 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))