Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1439409

[PATCH v2 2/4] xen-blkback: prefer xenbus_scanf() over xenbus_gather()

From "Jan Beulich" <JBeulich@suse.com>
Newsgroups linux.kernel
Subject [PATCH v2 2/4] xen-blkback: prefer xenbus_scanf() over xenbus_gather()
Date 2016-07-08 14:30 +0200
Message-ID <rSD4T-4Jb-69@gated-at.bofh.it> (permalink)
References <rSD4S-4Jb-13@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


For single items being collected this should be preferred as being more
typesafe (as the compiler can check format string and to-be-written-to
variable match) and more efficient (requiring one less parameter to be
passed).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Roger Pau Monné <roger.pau@citrix.com>
---
v2: Avoid commit message to continue from subject.
---
 drivers/block/xen-blkback/xenbus.c |   13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

--- 4.7-rc6-prefer-xenbus_scanf.orig/drivers/block/xen-blkback/xenbus.c
+++ 4.7-rc6-prefer-xenbus_scanf/drivers/block/xen-blkback/xenbus.c
@@ -1022,9 +1022,9 @@ static int connect_ring(struct backend_i
 	pr_debug("%s %s\n", __func__, dev->otherend);
 
 	be->blkif->blk_protocol = BLKIF_PROTOCOL_DEFAULT;
-	err = xenbus_gather(XBT_NIL, dev->otherend, "protocol",
-			    "%63s", protocol, NULL);
-	if (err)
+	err = xenbus_scanf(XBT_NIL, dev->otherend, "protocol",
+			   "%63s", protocol);
+	if (err <= 0)
 		strcpy(protocol, "unspecified, assuming default");
 	else if (0 == strcmp(protocol, XEN_IO_PROTO_ABI_NATIVE))
 		be->blkif->blk_protocol = BLKIF_PROTOCOL_NATIVE;
@@ -1036,10 +1036,9 @@ static int connect_ring(struct backend_i
 		xenbus_dev_fatal(dev, err, "unknown fe protocol %s", protocol);
 		return -ENOSYS;
 	}
-	err = xenbus_gather(XBT_NIL, dev->otherend,
-			    "feature-persistent", "%u",
-			    &pers_grants, NULL);
-	if (err)
+	err = xenbus_scanf(XBT_NIL, dev->otherend,
+			   "feature-persistent", "%u", &pers_grants);
+	if (err <= 0)
 		pers_grants = 0;
 
 	be->blkif->vbd.feature_gnt_persistent = pers_grants;

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v2 0/4] xen: prefer xenbus_scanf() over xenbus_gather() "Jan Beulich" <JBeulich@suse.com> - 2016-07-08 14:30 +0200
  [PATCH v2 3/4] xen-blkfront: prefer xenbus_scanf() over  xenbus_gather() "Jan Beulich" <JBeulich@suse.com> - 2016-07-08 14:30 +0200
  [PATCH v2 1/4] xenbus: prefer xenbus_scanf() over  xenbus_gather() "Jan Beulich" <JBeulich@suse.com> - 2016-07-08 14:30 +0200
  [PATCH v2 2/4] xen-blkback: prefer xenbus_scanf() over  xenbus_gather() "Jan Beulich" <JBeulich@suse.com> - 2016-07-08 14:30 +0200
  Re: [Xen-devel] [PATCH v2 0/4] xen: prefer xenbus_scanf() over  xenbus_gather() Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> - 2016-07-08 16:20 +0200
    Re: [Xen-devel] [PATCH v2 0/4] xen: prefer xenbus_scanf() over  xenbus_gather() "Jan Beulich" <JBeulich@suse.com> - 2016-07-08 17:10 +0200
      Re: [Xen-devel] [PATCH v2 0/4] xen: prefer xenbus_scanf() over  xenbus_gather() Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> - 2016-07-08 17:20 +0200
    Re: [Xen-devel] [PATCH v2 0/4] xen: prefer xenbus_scanf() over  xenbus_gather() David Vrabel <david.vrabel@citrix.com> - 2016-07-08 17:50 +0200
      Re: [Xen-devel] [PATCH v2 0/4] xen: prefer xenbus_scanf() over  xenbus_gather() Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> - 2016-07-08 18:00 +0200

csiph-web