Skip to contentSkip to conversation

xen/manage: correct return value check on xenbus_scanf()

PATCH Juergen Gross 1 participant 2 messages Nov 8, 2016 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Juergen Gross

author Reviewed-by
#1 lore raw
Quoted 4 lines · Jan Beulich

A negative return value indicates an error; in fact the function at present won't ever return zero.

Quoted 13 lines

---
v2: For consistency with other code don't consider zero an error
(utilizing that xenbus_scanf() at present won't return zero). Adjust commit message accordingly.

---
 drivers/xen/manage.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

drivers/xen/manage.c static void sysrq_handler(struct xenbus_ · line 283

Quoted 8 lines
drivers/xen/manage.c +1 -1
@@ -277,7 +277,7 @@ static void sysrq_handler(struct xenbus_
 	err = xenbus_transaction_start(&xbt);
 	if (err)
 		return;
-	if (!xenbus_scanf(xbt, "control", "sysrq", "%c", &sysrq_key)) {
+	if (xenbus_scanf(xbt, "control", "sysrq", "%c", &sysrq_key) < 0) {
 		pr_err("Unable to read sysrq code in control/sysrq\n");
 		xenbus_transaction_end(xbt, 1);
 		return;

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

author Reviewed-by
#2 lore raw
In reply to a message not in the archive
Quoted 4 lines · Jan Beulich

A negative return value indicates an error; in fact the function at present won't ever return zero.

Quoted 21 lines

---
v2: For consistency with other code don't consider zero an error
(utilizing that xenbus_scanf() at present won't return zero). Adjust commit message accordingly.

---
 drivers/xen/manage.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/xen/manage.c +1 -1
@@ -277,7 +277,7 @@ static void sysrq_handler(struct xenbus_
 	err = xenbus_transaction_start(&xbt);
 	if (err)
 		return;
-	if (!xenbus_scanf(xbt, "control", "sysrq", "%c", &sysrq_key)) {
+	if (xenbus_scanf(xbt, "control", "sysrq", "%c", &sysrq_key) < 0) {
 		pr_err("Unable to read sysrq code in control/sysrq\n");
 		xenbus_transaction_end(xbt, 1);
 		return;