From: Ian Campbell Subject: Re: [PATCH 2/2 v2] xenstore: check F_SETFL fcntl invocation in setnonblock Date: Mon, 2 Dec 2013 11:41:10 +0000 Message-ID: <1385984470.7108.51.camel@kazak.uk.xensource.com> References: <1385770805-1929-3-git-send-email-mattd@bugfuzz.com> <1385771454-14153-1-git-send-email-mattd@bugfuzz.com> <21148.28836.285823.267431@mariner.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <21148.28836.285823.267431@mariner.uk.xensource.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: Ian Jackson Cc: Matthew Daley , Stefano Stabellini , xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org On Mon, 2013-12-02 at 11:36 +0000, Ian Jackson wrote: > Matthew Daley writes ("[PATCH 2/2 v2] xenstore: check F_SETFL fcntl invocation in setnonblock"): > > ...and check the newly-added result of setnonblock itself where used. > ... > > -static void setnonblock(int fd, int nonblock) { > > - int esave = errno; > > +static bool setnonblock(int fd, int nonblock) { > > int flags = fcntl(fd, F_GETFL); > > if (flags == -1) > > - goto out; > > + return false; > > > > if (nonblock) > > flags |= O_NONBLOCK; > > else > > flags &= ~O_NONBLOCK; > > > > - fcntl(fd, F_SETFL, flags); > > -out: > > - errno = esave; > > + return fcntl(fd, F_SETFL, flags) != -1; > > fcntl F_SETFL returns 0 on success and -1 or error. But your > setnonblock is supposed to return 1 on success and 0 on error. The trailing "!= -1" should make the the case, shouldn't it? Ian.