xen: make use of xenbus_read_unsigned() in xen-pcifront
authorJuergen Gross <jgross@suse.com>
Mon, 31 Oct 2016 13:58:41 +0000 (14:58 +0100)
committerJuergen Gross <jgross@suse.com>
Mon, 7 Nov 2016 12:55:26 +0000 (13:55 +0100)
Use xenbus_read_unsigned() instead of xenbus_scanf() when possible.
This requires to change the type of the read from int to unsigned,
but this case has been wrong before: negative values are not allowed
for the modified case.

Cc: bhelgaas@google.com
Cc: linux-pci@vger.kernel.org
Signed-off-by: Juergen Gross <jgross@suse.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: David Vrabel <david.vrabel@citrix.com>
drivers/pci/xen-pcifront.c

index d6ff5e82377d29c719f84fdf4ab6b3db1400edf3..8fc2e9532575679ab60724201fa0181b1679c809 100644 (file)
@@ -1038,10 +1038,8 @@ static int pcifront_detach_devices(struct pcifront_device *pdev)
                        err = -ENOMEM;
                        goto out;
                }
-               err = xenbus_scanf(XBT_NIL, pdev->xdev->otherend, str, "%d",
-                                  &state);
-               if (err != 1)
-                       state = XenbusStateUnknown;
+               state = xenbus_read_unsigned(pdev->xdev->otherend, str,
+                                            XenbusStateUnknown);
 
                if (state != XenbusStateClosing)
                        continue;