Skip to content

Commit

Permalink
xen-blkback: prefer xenbus_scanf() over xenbus_gather()
Browse files Browse the repository at this point in the history
... for single items being collected: It is more typesafe (as the
compiler can check format string and to-be-written-to variable match)
and requires one less parameter to be passed.

Signed-off-by: Jan Beulich <[email protected]>
Signed-off-by: Konrad Rzeszutek Wilk <[email protected]>
Acked-by: Roger Pau Monné <[email protected]>
Acked-by: Jens Axboe <[email protected]>
  • Loading branch information
jbeulich authored and konradwilk committed Jul 22, 2016
1 parent 6ba286a commit 6694389
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions drivers/block/xen-blkback/xenbus.c
Original file line number Diff line number Diff line change
Expand Up @@ -1022,9 +1022,9 @@ static int connect_ring(struct backend_info *be)
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;
Expand All @@ -1036,10 +1036,9 @@ static int connect_ring(struct backend_info *be)
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;
Expand Down

0 comments on commit 6694389

Please sign in to comment.