From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ian Campbell Subject: Re: [PATCH v2] blktap2: update connection handling to fix build with gcc5 Date: Tue, 21 Jul 2015 09:52:44 +0100 Message-ID: <1437468764.17368.83.camel@citrix.com> References: <1437468128-591-1-git-send-email-olaf@aepfle.de> <55AE236D020000780009386A@prv-mh.provo.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <55AE236D020000780009386A@prv-mh.provo.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Jan Beulich Cc: Ian Jackson , Olaf Hering , xen-devel@lists.xen.org, Wei Liu , Stefano Stabellini List-Id: xen-devel@lists.xenproject.org On Tue, 2015-07-21 at 02:48 -0600, Jan Beulich wrote: > >>> On 21.07.15 at 10:42, wrote: > > --- a/tools/blktap2/drivers/block-log.c > > +++ b/tools/blktap2/drivers/block-log.c > > @@ -359,7 +359,7 @@ static int ctl_close_sock(struct tdlog_state* s, int fd) > > { > > int i; > > > > - for (i = 0; i < s->connected; i++) { > > + for (i = 0; i < s->connected && i < MAX_CONNECTIONS; i++) { > > if (s->connections[i].fd == fd) { > > tapdisk_server_unregister_event(s->connections[i].id); > > close(s->connections[i].fd); > > @@ -545,7 +545,7 @@ static inline int ctl_find_connection(struct tdlog_state *s, event_id_t id) > > { > > int i; > > > > - for (i = 0; i < s->connected; i++) > > + for (i = 0; i < s->connected && i < MAX_CONNECTIONS; i++) > > if (s->connections[i].id == id) > > return s->connections[i].fd; > > > > Which now makes the reader (wrongly) imply that s->connected > might be equal to or larger than MAX_CONNECTIONS. I was just thinking that perhaps either an assert() or an: if ( s->connected >= MAX_CONNECTIONS ) { log return error } might be more appropriate. Ian.