From: "Jan Beulich" Subject: Re: [PATCH] blktap2: update connection handling to fix build with gcc5 Date: Mon, 20 Jul 2015 10:09:00 +0100 Message-ID: <55ACD6CC0200007800092F33@mail.emea.novell.com> References: <1437298408-23414-1-git-send-email-olaf@aepfle.de> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1437298408-23414-1-git-send-email-olaf@aepfle.de> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Olaf Hering Cc: Ian Jackson , xen-devel@lists.xen.org, Wei Liu , Ian Campbell , Stefano Stabellini List-Id: xen-devel@lists.xenproject.org >>> On 19.07.15 at 11:33, wrote: > blktap2 fails to build with gcc5 because it fails to recognize that > there can be just one active connection (enforced in ctl_accept). > > Rearrange the code to handle just a single connection. > Adjust two strerror calls to use errno instead -1 as input. > > [ 198s] block-log.c: In function 'ctl_close_sock': > [ 198s] block-log.c:363:23: error: array subscript is above array bounds [-Werror=array-bounds] > [ 198s] if (s->connections[i].fd == fd) { > [ 198s] ^ > [ 198s] block-log.c: In function 'ctl_request': > [ 198s] block-log.c:549:23: error: array subscript is above array bounds [-Werror=array-bounds] > [ 198s] if (s->connections[i].id == id) > [ 198s] ^ So what makes the compiler right with that complaint? I.e. how does it know i > 0 here? After all - afaict - s->connected can only be 0 or 1, and hence either the loop bodies don't get entered at all or the loops have only a single iteration. Smells like a compiler bug instead, which I'm not sure we want to work around with a non-trivial patch like this. Jan