[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH v2] blktap2: update connection handling to fix build with gcc5
On Tue, 2015-07-21 at 02:48 -0600, Jan Beulich wrote: > >>> On 21.07.15 at 10:42, <olaf@xxxxxxxxx> 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. _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |