Skip to contentSkip to conversation

xen-fbfront: correct return value checks on xenbus_scanf()

PATCH Juergen Gross 2 participants 2 messages Jul 7, 2016 1 message not in the archive Framebuffer layer

lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive
Quoted 1 line · Jan Beulich

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

Quoted 26 lines
---
 drivers/video/fbdev/xen-fbfront.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/video/fbdev/xen-fbfront.c +2 -2
@@ -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;
#2 lore raw
Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 07.07.16 at 11:42, <[email protected]> wrote:
Quoted 1 line · Jan Beulich

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