From: Daniel De Graaf Subject: Re: [PATCH 25/29] libvchan: check for fcntl failures in select-type sample application Date: Wed, 30 Oct 2013 13:06:28 -0400 Message-ID: <52713C94.1050001@tycho.nsa.gov> References: <1383119525-26033-1-git-send-email-mattjd@gmail.com> <1383119525-26033-26-git-send-email-mattjd@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1383119525-26033-26-git-send-email-mattjd@gmail.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: Matthew Daley Cc: Stefano Stabellini , Ian Jackson , Ian Campbell , xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org On 10/30/2013 03:52 AM, Matthew Daley wrote: > Coverity-ID: 1055041 > Signed-off-by: Matthew Daley > --- > tools/libvchan/node-select.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/tools/libvchan/node-select.c b/tools/libvchan/node-select.c > index 6c6c19e..c6914ab 100644 > --- a/tools/libvchan/node-select.c > +++ b/tools/libvchan/node-select.c > @@ -105,8 +105,10 @@ int main(int argc, char **argv) > exit(1); > } > > - fcntl(0, F_SETFL, O_NONBLOCK); > - fcntl(1, F_SETFL, O_NONBLOCK); > + if (fcntl(0, F_SETFL, O_NONBLOCK) == -1 || fcntl(1, F_SETFL, O_NONBLOCK) == -1) { > + perror("fcntl"); > + exit(1); > + } > > libxenvchan_fd = libxenvchan_fd_for_select(ctrl); > for (;;) { > To be completely correct, a call to F_GETFL would be required first, with the result ORed with O_NONBLOCK and passed to F_SETFL. That is a separate existing bug in the code, however, so this patch is still an improvement as-is. Is the fcntl on line 156 different in some way that does not trigger this Coverity check? -- Daniel De Graaf National Security Agency