xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Matthew Daley <mattd@bugfuzz.com>, xen-devel@lists.xen.org
Cc: Ian Jackson <ian.jackson@eu.citrix.com>,
	Ian Campbell <ian.campbell@citrix.com>,
	Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Subject: Re: [PATCH 2/2 v2] xenstore: check F_SETFL fcntl invocation in setnonblock
Date: Sun, 1 Dec 2013 11:48:04 +0000	[thread overview]
Message-ID: <529B21F4.4000705@citrix.com> (raw)
In-Reply-To: <1385771454-14153-1-git-send-email-mattd@bugfuzz.com>

On 30/11/2013 00:30, Matthew Daley wrote:
> ...and check the newly-added result of setnonblock itself where used.
>
> Coverity-ID: 1055103
> Signed-off-by: Matthew Daley <mattd@bugfuzz.com>

Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>

> ---
> v2: return false -> goto out_false
>
>  tools/xenstore/xs.c |   16 +++++++---------
>  1 file changed, 7 insertions(+), 9 deletions(-)
>
> diff --git a/tools/xenstore/xs.c b/tools/xenstore/xs.c
> index 184886f..504d524 100644
> --- a/tools/xenstore/xs.c
> +++ b/tools/xenstore/xs.c
> @@ -146,20 +146,17 @@ struct xs_handle {
>  
>  static int read_message(struct xs_handle *h, int nonblocking);
>  
> -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;
>  }
>  
>  int xs_fileno(struct xs_handle *h)
> @@ -369,8 +366,8 @@ static bool read_all(int fd, void *data, unsigned int len, int nonblocking)
>  	if (!len)
>  		return true;
>  
> -	if (nonblocking)
> -		setnonblock(fd, 1);
> +	if (nonblocking && !setnonblock(fd, 1))
> +		return false;
>  
>  	while (len) {
>  		int done;
> @@ -390,8 +387,9 @@ static bool read_all(int fd, void *data, unsigned int len, int nonblocking)
>  		len -= done;
>  
>  		if (nonblocking) {
> -			setnonblock(fd, 0);
>  			nonblocking = 0;
> +			if (!setnonblock(fd, 0))
> +				goto out_false;
>  		}
>  	}
>  

  reply	other threads:[~2013-12-01 11:48 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-30  0:20 Minor Coverity xenstore fixes Matthew Daley
2013-11-30  0:20 ` [PATCH 1/2] xenstore: sanity check incoming message body lengths Matthew Daley
2013-12-01 11:44   ` Andrew Cooper
2013-12-19 15:42     ` [PATCH 1/2] xenstore: sanity check incoming message body lengths [and 2 more messages] Ian Jackson
2013-12-19 15:51       ` Ian Campbell
2013-12-19 17:17         ` Ian Jackson
2013-12-02 11:33   ` [PATCH 1/2] xenstore: sanity check incoming message body lengths Ian Jackson
2013-12-02 11:53     ` Matthew Daley
2013-11-30  0:20 ` [PATCH 2/2] xenstore: check F_SETFL fcntl invocation in setnonblock Matthew Daley
2013-11-30  0:30   ` [PATCH 2/2 v2] " Matthew Daley
2013-12-01 11:48     ` Andrew Cooper [this message]
2013-12-02 11:36     ` Ian Jackson
2013-12-02 11:41       ` Ian Campbell
2013-12-02 12:34         ` Ian Jackson
2013-12-02 12:45           ` Matthew Daley
2013-12-13  5:55             ` Matthew Daley
2013-12-13 16:56               ` Ian Jackson
2013-11-30  1:33 ` Minor Coverity xenstore fixes Matthew Daley

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=529B21F4.4000705@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=ian.campbell@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=mattd@bugfuzz.com \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).