xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH] xen-kbdfront: correct return value checks on xenbus_scanf()
       [not found] <577E26A402000078000FBE93@prv-mh.provo.novell.com>
@ 2016-07-09  0:33 ` Dmitry Torokhov
  0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Torokhov @ 2016-07-09  0:33 UTC (permalink / raw)
  To: Jan Beulich
  Cc: Juergen Gross, xen-devel, boris.ostrovsky, david.vrabel, linux-input

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

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH] xen-kbdfront: correct return value checks on xenbus_scanf()
@ 2016-07-07  7:53 Jan Beulich
  0 siblings, 0 replies; 2+ messages in thread
From: Jan Beulich @ 2016-07-07  7:53 UTC (permalink / raw)
  To: dmitry.torokhov
  Cc: Juergen Gross, xen-devel, boris.ostrovsky, david.vrabel, linux-input

Only a positive return value indicates success.

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,




_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-07-09  0:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <577E26A402000078000FBE93@prv-mh.provo.novell.com>
2016-07-09  0:33 ` [PATCH] xen-kbdfront: correct return value checks on xenbus_scanf() Dmitry Torokhov
2016-07-07  7:53 Jan Beulich

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).