All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xen-fbfront: correct return value checks on xenbus_scanf()
@ 2016-07-07  7:48 ` Jan Beulich
  0 siblings, 0 replies; 8+ messages in thread
From: Jan Beulich @ 2016-07-07  7:48 UTC (permalink / raw)
  To: plagnioj, tomi.valkeinen
  Cc: Juergen Gross, xen-devel, Boris Ostrovsky, David Vrabel, linux-fbdev

Only a positive return value indicates success.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
 drivers/video/fbdev/xen-fbfront.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- 4.7-rc6-xenbus_scanf.orig/drivers/video/fbdev/xen-fbfront.c
+++ 4.7-rc6-xenbus_scanf/drivers/video/fbdev/xen-fbfront.c
@@ -658,13 +658,13 @@ InitWait:
 			goto InitWait; /* no InitWait seen yet, fudge it */
 
 		if (xenbus_scanf(XBT_NIL, info->xbdev->otherend,
-				 "request-update", "%d", &val) < 0)
+				 "request-update", "%d", &val) <= 0)
 			val = 0;
 		if (val)
 			info->update_wanted = 1;
 
 		if (xenbus_scanf(XBT_NIL, dev->otherend,
-				 "feature-resize", "%d", &val) < 0)
+				 "feature-resize", "%d", &val) <= 0)
 			val = 0;
 		info->feature_resize = val;
 		break;




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

* [PATCH] xen-fbfront: correct return value checks on xenbus_scanf()
@ 2016-07-07  7:48 ` Jan Beulich
  0 siblings, 0 replies; 8+ messages in thread
From: Jan Beulich @ 2016-07-07  7:48 UTC (permalink / raw)
  To: plagnioj, tomi.valkeinen
  Cc: Juergen Gross, xen-devel, Boris Ostrovsky, David Vrabel, linux-fbdev

Only a positive return value indicates success.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
 drivers/video/fbdev/xen-fbfront.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- 4.7-rc6-xenbus_scanf.orig/drivers/video/fbdev/xen-fbfront.c
+++ 4.7-rc6-xenbus_scanf/drivers/video/fbdev/xen-fbfront.c
@@ -658,13 +658,13 @@ InitWait:
 			goto InitWait; /* no InitWait seen yet, fudge it */
 
 		if (xenbus_scanf(XBT_NIL, info->xbdev->otherend,
-				 "request-update", "%d", &val) < 0)
+				 "request-update", "%d", &val) <= 0)
 			val = 0;
 		if (val)
 			info->update_wanted = 1;
 
 		if (xenbus_scanf(XBT_NIL, dev->otherend,
-				 "feature-resize", "%d", &val) < 0)
+				 "feature-resize", "%d", &val) <= 0)
 			val = 0;
 		info->feature_resize = val;
 		break;




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

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

* Re: [Xen-devel] [PATCH] xen-fbfront: correct return value checks on xenbus_scanf()
  2016-07-07  7:48 ` Jan Beulich
@ 2016-07-07  9:46   ` David Vrabel
  -1 siblings, 0 replies; 8+ messages in thread
From: David Vrabel @ 2016-07-07  9:46 UTC (permalink / raw)
  To: Jan Beulich, plagnioj, tomi.valkeinen
  Cc: Juergen Gross, xen-devel, Boris Ostrovsky, David Vrabel, linux-fbdev

On 07/07/16 08:48, Jan Beulich wrote:
> 
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> ---
>  drivers/video/fbdev/xen-fbfront.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> --- 4.7-rc6-xenbus_scanf.orig/drivers/video/fbdev/xen-fbfront.c
> +++ 4.7-rc6-xenbus_scanf/drivers/video/fbdev/xen-fbfront.c
> @@ -658,13 +658,13 @@ InitWait:
>  			goto InitWait; /* no InitWait seen yet, fudge it */
>  
>  		if (xenbus_scanf(XBT_NIL, info->xbdev->otherend,
> -				 "request-update", "%d", &val) < 0)
> +				 "request-update", "%d", &val) <= 0)
>  			val = 0;
>  		if (val)
>  			info->update_wanted = 1;
>  
>  		if (xenbus_scanf(XBT_NIL, dev->otherend,
> -				 "feature-resize", "%d", &val) < 0)
> +				 "feature-resize", "%d", &val) <= 0)

xenbus_scanf() has:

/* Single read and scanf: returns -errno or num scanned. */
...
        if (ret = 0)
                return -ERANGE;
...

So none of these patches are necessary.

David

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

* Re: [PATCH] xen-fbfront: correct return value checks on xenbus_scanf()
@ 2016-07-07  9:46   ` David Vrabel
  0 siblings, 0 replies; 8+ messages in thread
From: David Vrabel @ 2016-07-07  9:46 UTC (permalink / raw)
  To: Jan Beulich, plagnioj, tomi.valkeinen
  Cc: Juergen Gross, xen-devel, Boris Ostrovsky, David Vrabel, linux-fbdev

On 07/07/16 08:48, Jan Beulich wrote:
> 
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> ---
>  drivers/video/fbdev/xen-fbfront.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> --- 4.7-rc6-xenbus_scanf.orig/drivers/video/fbdev/xen-fbfront.c
> +++ 4.7-rc6-xenbus_scanf/drivers/video/fbdev/xen-fbfront.c
> @@ -658,13 +658,13 @@ InitWait:
>  			goto InitWait; /* no InitWait seen yet, fudge it */
>  
>  		if (xenbus_scanf(XBT_NIL, info->xbdev->otherend,
> -				 "request-update", "%d", &val) < 0)
> +				 "request-update", "%d", &val) <= 0)
>  			val = 0;
>  		if (val)
>  			info->update_wanted = 1;
>  
>  		if (xenbus_scanf(XBT_NIL, dev->otherend,
> -				 "feature-resize", "%d", &val) < 0)
> +				 "feature-resize", "%d", &val) <= 0)

xenbus_scanf() has:

/* Single read and scanf: returns -errno or num scanned. */
...
        if (ret == 0)
                return -ERANGE;
...

So none of these patches are necessary.

David

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

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

* Re: [PATCH] xen-fbfront: correct return value checks on xenbus_scanf()
  2016-07-07  9:42   ` Juergen Gross
@ 2016-07-07 10:03     ` Jan Beulich
  -1 siblings, 0 replies; 8+ messages in thread
From: Jan Beulich @ 2016-07-07 10:03 UTC (permalink / raw)
  To: David Vrabel, Juergen Gross
  Cc: xen-devel, Boris Ostrovsky, tomi.valkeinen, plagnioj, linux-fbdev

>>> On 07.07.16 at 11:42, <JGross@suse.com> wrote:
> On 07/07/16 09:48, Jan Beulich wrote:
>> Only a positive return value indicates success.
> 
> Hmm, I'm not convinced on this change (and the similar others as
> well). From xenbus.h:
> 
> /* Single read and scanf: returns -errno or num scanned if > 0. */
> 
> There should be no case for xenbus_scanf() returning 0. And looking
> into the functions proofs this is correct.

I don't think it is appropriate for callers to assume a currently
impossible return value indicates success.

Jan


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

* Re: [PATCH] xen-fbfront: correct return value checks on xenbus_scanf()
@ 2016-07-07 10:03     ` Jan Beulich
  0 siblings, 0 replies; 8+ messages in thread
From: Jan Beulich @ 2016-07-07 10:03 UTC (permalink / raw)
  To: David Vrabel, Juergen Gross
  Cc: xen-devel, Boris Ostrovsky, tomi.valkeinen, plagnioj, linux-fbdev

>>> On 07.07.16 at 11:42, <JGross@suse.com> wrote:
> On 07/07/16 09:48, Jan Beulich wrote:
>> Only a positive return value indicates success.
> 
> Hmm, I'm not convinced on this change (and the similar others as
> well). From xenbus.h:
> 
> /* Single read and scanf: returns -errno or num scanned if > 0. */
> 
> There should be no case for xenbus_scanf() returning 0. And looking
> into the functions proofs this is correct.

I don't think it is appropriate for callers to assume a currently
impossible return value indicates success.

Jan


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

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

* Re: [PATCH] xen-fbfront: correct return value checks on xenbus_scanf()
       [not found] <577E258502000078000FBE6F@suse.com>
@ 2016-07-07  9:42   ` Juergen Gross
  0 siblings, 0 replies; 8+ messages in thread
From: Juergen Gross @ 2016-07-07  9:42 UTC (permalink / raw)
  To: Jan Beulich, plagnioj, tomi.valkeinen
  Cc: xen-devel, Boris Ostrovsky, David Vrabel, linux-fbdev

On 07/07/16 09:48, Jan Beulich wrote:
> Only a positive return value indicates success.

Hmm, I'm not convinced on this change (and the similar others as
well). From xenbus.h:

/* Single read and scanf: returns -errno or num scanned if > 0. */

There should be no case for xenbus_scanf() returning 0. And looking
into the functions proofs this is correct.


Juergen

> 
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> ---
>  drivers/video/fbdev/xen-fbfront.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> --- 4.7-rc6-xenbus_scanf.orig/drivers/video/fbdev/xen-fbfront.c
> +++ 4.7-rc6-xenbus_scanf/drivers/video/fbdev/xen-fbfront.c
> @@ -658,13 +658,13 @@ InitWait:
>  			goto InitWait; /* no InitWait seen yet, fudge it */
>  
>  		if (xenbus_scanf(XBT_NIL, info->xbdev->otherend,
> -				 "request-update", "%d", &val) < 0)
> +				 "request-update", "%d", &val) <= 0)
>  			val = 0;
>  		if (val)
>  			info->update_wanted = 1;
>  
>  		if (xenbus_scanf(XBT_NIL, dev->otherend,
> -				 "feature-resize", "%d", &val) < 0)
> +				 "feature-resize", "%d", &val) <= 0)
>  			val = 0;
>  		info->feature_resize = val;
>  		break;
> 
> 


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

* Re: [PATCH] xen-fbfront: correct return value checks on xenbus_scanf()
@ 2016-07-07  9:42   ` Juergen Gross
  0 siblings, 0 replies; 8+ messages in thread
From: Juergen Gross @ 2016-07-07  9:42 UTC (permalink / raw)
  To: Jan Beulich, plagnioj, tomi.valkeinen
  Cc: xen-devel, Boris Ostrovsky, David Vrabel, linux-fbdev

On 07/07/16 09:48, Jan Beulich wrote:
> Only a positive return value indicates success.

Hmm, I'm not convinced on this change (and the similar others as
well). From xenbus.h:

/* Single read and scanf: returns -errno or num scanned if > 0. */

There should be no case for xenbus_scanf() returning 0. And looking
into the functions proofs this is correct.


Juergen

> 
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> ---
>  drivers/video/fbdev/xen-fbfront.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> --- 4.7-rc6-xenbus_scanf.orig/drivers/video/fbdev/xen-fbfront.c
> +++ 4.7-rc6-xenbus_scanf/drivers/video/fbdev/xen-fbfront.c
> @@ -658,13 +658,13 @@ InitWait:
>  			goto InitWait; /* no InitWait seen yet, fudge it */
>  
>  		if (xenbus_scanf(XBT_NIL, info->xbdev->otherend,
> -				 "request-update", "%d", &val) < 0)
> +				 "request-update", "%d", &val) <= 0)
>  			val = 0;
>  		if (val)
>  			info->update_wanted = 1;
>  
>  		if (xenbus_scanf(XBT_NIL, dev->otherend,
> -				 "feature-resize", "%d", &val) < 0)
> +				 "feature-resize", "%d", &val) <= 0)
>  			val = 0;
>  		info->feature_resize = val;
>  		break;
> 
> 


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

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

end of thread, other threads:[~2016-07-07 10:03 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-07  7:48 [PATCH] xen-fbfront: correct return value checks on xenbus_scanf() Jan Beulich
2016-07-07  7:48 ` Jan Beulich
2016-07-07  9:46 ` [Xen-devel] " David Vrabel
2016-07-07  9:46   ` David Vrabel
     [not found] <577E258502000078000FBE6F@suse.com>
2016-07-07  9:42 ` Juergen Gross
2016-07-07  9:42   ` Juergen Gross
2016-07-07 10:03   ` Jan Beulich
2016-07-07 10:03     ` Jan Beulich

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.