linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: david.vrabel@citrix.com, xen-devel@lists.xenproject.org,
	boris.ostrovsky@oracle.com, Juergen Gross <JGross@suse.com>,
	linux-input@vger.kernel.org
Subject: Re: [PATCH] xen-kbdfront: correct return value checks on xenbus_scanf()
Date: Fri, 8 Jul 2016 17:33:29 -0700	[thread overview]
Message-ID: <20160709003329.GJ28589@dtor-ws> (raw)
In-Reply-To: <577E26A402000078000FBE93@prv-mh.provo.novell.com>

On Thu, Jul 07, 2016 at 01:53:40AM -0600, Jan Beulich wrote:
> Only a positive return value indicates success.

If I am reading this correctly xenbus_scanf() guarantees that it will
not return 0. From include/xen/xenbus.h:

/* Single read and scanf: returns -errno or num scanned if > 0. */
__scanf(4, 5)
int xenbus_scanf(struct xenbus_transaction t,
		 const char *dir, const char *node, const char *fmt, ...);

and the code matches:

	...
	/* Distinctive errno. */
	if (ret == 0)
		return -ERANGE;
	return ret;

> 
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> ---
>  drivers/input/misc/xen-kbdfront.c |    5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> --- 4.7-rc6-xenbus_scanf.orig/drivers/input/misc/xen-kbdfront.c
> +++ 4.7-rc6-xenbus_scanf/drivers/input/misc/xen-kbdfront.c
> @@ -127,7 +127,8 @@ static int xenkbd_probe(struct xenbus_de
>  	if (!info->page)
>  		goto error_nomem;
>  
> -	if (xenbus_scanf(XBT_NIL, dev->otherend, "feature-abs-pointer", "%d", &abs) < 0)
> +	if (xenbus_scanf(XBT_NIL, dev->otherend,
> +			 "feature-abs-pointer", "%d", &abs) <= 0)
>  		abs = 0;
>  	if (abs) {
>  		ret = xenbus_printf(XBT_NIL, dev->nodename,
> @@ -324,7 +325,7 @@ static void xenkbd_backend_changed(struc
>  InitWait:
>  		ret = xenbus_scanf(XBT_NIL, info->xbdev->otherend,
>  				   "feature-abs-pointer", "%d", &val);
> -		if (ret < 0)
> +		if (ret <= 0)
>  			val = 0;
>  		if (val) {
>  			ret = xenbus_printf(XBT_NIL, info->xbdev->nodename,
> 
> 

Thanks.

-- 
Dmitry

      reply	other threads:[~2016-07-09  0:33 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-07  7:53 [PATCH] xen-kbdfront: correct return value checks on xenbus_scanf() Jan Beulich
2016-07-09  0:33 ` Dmitry Torokhov [this message]

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=20160709003329.GJ28589@dtor-ws \
    --to=dmitry.torokhov@gmail.com \
    --cc=JBeulich@suse.com \
    --cc=JGross@suse.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=david.vrabel@citrix.com \
    --cc=linux-input@vger.kernel.org \
    --cc=xen-devel@lists.xenproject.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).