Skip to content

Commit

Permalink
xen-blkfront: 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.

Acked-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
  • Loading branch information
Jan Beulich authored and Konrad Rzeszutek Wilk committed Jul 22, 2016
1 parent 6694389 commit ff59532
Showing 1 changed file with 19 additions and 24 deletions.
43 changes: 19 additions & 24 deletions drivers/block/xen-blkfront.c
Original file line number Diff line number Diff line change
Expand Up @@ -2208,10 +2208,9 @@ static void blkfront_setup_discard(struct blkfront_info *info)
info->discard_granularity = discard_granularity;
info->discard_alignment = discard_alignment;
}
err = xenbus_gather(XBT_NIL, info->xbdev->otherend,
"discard-secure", "%d", &discard_secure,
NULL);
if (!err)
err = xenbus_scanf(XBT_NIL, info->xbdev->otherend,
"discard-secure", "%u", &discard_secure);
if (err > 0)
info->feature_secdiscard = !!discard_secure;
}

Expand Down Expand Up @@ -2310,9 +2309,8 @@ static void blkfront_gather_backend_features(struct blkfront_info *info)

info->feature_flush = 0;

err = xenbus_gather(XBT_NIL, info->xbdev->otherend,
"feature-barrier", "%d", &barrier,
NULL);
err = xenbus_scanf(XBT_NIL, info->xbdev->otherend,
"feature-barrier", "%d", &barrier);

/*
* If there's no "feature-barrier" defined, then it means
Expand All @@ -2321,38 +2319,35 @@ static void blkfront_gather_backend_features(struct blkfront_info *info)
*
* If there are barriers, then we use flush.
*/
if (!err && barrier)
if (err > 0 && barrier)
info->feature_flush = REQ_FLUSH | REQ_FUA;
/*
* And if there is "feature-flush-cache" use that above
* barriers.
*/
err = xenbus_gather(XBT_NIL, info->xbdev->otherend,
"feature-flush-cache", "%d", &flush,
NULL);
err = xenbus_scanf(XBT_NIL, info->xbdev->otherend,
"feature-flush-cache", "%d", &flush);

if (!err && flush)
if (err > 0 && flush)
info->feature_flush = REQ_FLUSH;

err = xenbus_gather(XBT_NIL, info->xbdev->otherend,
"feature-discard", "%d", &discard,
NULL);
err = xenbus_scanf(XBT_NIL, info->xbdev->otherend,
"feature-discard", "%d", &discard);

if (!err && discard)
if (err > 0 && discard)
blkfront_setup_discard(info);

err = xenbus_gather(XBT_NIL, info->xbdev->otherend,
"feature-persistent", "%u", &persistent,
NULL);
if (err)
err = xenbus_scanf(XBT_NIL, info->xbdev->otherend,
"feature-persistent", "%d", &persistent);
if (err <= 0)
info->feature_persistent = 0;
else
info->feature_persistent = persistent;

err = xenbus_gather(XBT_NIL, info->xbdev->otherend,
"feature-max-indirect-segments", "%u", &indirect_segments,
NULL);
if (err)
err = xenbus_scanf(XBT_NIL, info->xbdev->otherend,
"feature-max-indirect-segments", "%u",
&indirect_segments);
if (err <= 0)
info->max_indirect_segments = 0;
else
info->max_indirect_segments = min(indirect_segments,
Expand Down

0 comments on commit ff59532

Please sign in to comment.