From patchwork Thu Jul 7 08:05:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 9218199 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D994F6048B for ; Thu, 7 Jul 2016 08:07:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CE75D2878F for ; Thu, 7 Jul 2016 08:07:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C33672879D; Thu, 7 Jul 2016 08:07:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 51C842878F for ; Thu, 7 Jul 2016 08:07:58 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bL4Jk-0003Xl-JD; Thu, 07 Jul 2016 08:05:52 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bL4Jj-0003XY-Oh for xen-devel@lists.xenproject.org; Thu, 07 Jul 2016 08:05:51 +0000 Received: from [85.158.139.211] by server-11.bemta-5.messagelabs.com id 73/93-04210-F5D0E775; Thu, 07 Jul 2016 08:05:51 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFuphkeJIrShJLcpLzFFi42LpdPzhpRvHWxd u8PAUv8X3LZOZHBg9Dn+4whLAGMWamZeUX5HAmnFwwUymguXiFZ9WvWdpYDwh3MXIySEkkCcx 8/kZdhCbV8BO4veiiSwgtoSAocS++avYQGwWAVWJS52TmUFsNgF1ibZn21m7GDk4RATiJR6/C wIJMws4S2xc1g7WKizgJbH4wQmwEl4BQYm/O4QhSrQkHv66xQJha0ssW/iaGaSEWUBaYvk/jg mMPLMQGmYhaZiFpGEWQsMCRpZVjBrFqUVlqUW6RpZ6SUWZ6RkluYmZObqGBqZ6uanFxYnpqTm JScV6yfm5mxiBoVTPwMC4g/HyFr9DjJIcTEqivHvu1oYL8SXlp1RmJBZnxBeV5qQWH2KU4eBQ kuDV4qkLFxIsSk1PrUjLzAEGNUxagoNHSYRXCSTNW1yQmFucmQ6ROsWoKCXOywOSEABJZJTmw bXBIukSo6yUMC8jAwODEE9BalFuZgmq/CtGcQ5GJWHeRJApPJl5JXDTXwEtZgJa/NOlGmRxSS JCSqqBcduS8r9rH77t4AnocFqQEcJ0/eHX0LP/YvPd9d/vUWPru5lVpt3tJ7uEacpn7cj08l+ T97QeqojUUIi9lH5xzZEtGoHWCapvsnpXNXuZOicdu/ZhiXb4rgMtDPnntEo5l8iacP5b7WnW cPOe9SX23Vc2Sx1/uu7Kyzfbj8vm3hSoMzcpbZfjUmIpzkg01GIuKk4EAOIppjufAgAA X-Env-Sender: JBeulich@suse.com X-Msg-Ref: server-5.tower-206.messagelabs.com!1467878748!48887315!1 X-Originating-IP: [137.65.248.74] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.46; banners=-,-,- X-VirusChecked: Checked Received: (qmail 27663 invoked from network); 7 Jul 2016 08:05:49 -0000 Received: from prv-mh.provo.novell.com (HELO prv-mh.provo.novell.com) (137.65.248.74) by server-5.tower-206.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 7 Jul 2016 08:05:49 -0000 Received: from INET-PRV-MTA by prv-mh.provo.novell.com with Novell_GroupWise; Thu, 07 Jul 2016 02:05:47 -0600 Message-Id: <577E297A02000078000FBF20@prv-mh.provo.novell.com> X-Mailer: Novell GroupWise Internet Agent 14.2.0 Date: Thu, 07 Jul 2016 02:05:46 -0600 From: "Jan Beulich" To: "Roger Pau Monne" , "Konrad Rzeszutek Wilk" Mime-Version: 1.0 Content-Disposition: inline Cc: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org Subject: [Xen-devel] [PATCH] xen-blkfront: prefer xenbus_scanf() over xenbus_gather() X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP ... 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 Acked-by: Roger Pau Monné --- drivers/block/xen-blkfront.c | 43 +++++++++++++++++++------------------------ 1 file changed, 19 insertions(+), 24 deletions(-) --- 4.7-rc6-prefer-xenbus_scanf.orig/drivers/block/xen-blkfront.c +++ 4.7-rc6-prefer-xenbus_scanf/drivers/block/xen-blkfront.c @@ -2208,10 +2208,9 @@ static void blkfront_setup_discard(struc 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; } @@ -2310,9 +2309,8 @@ static void blkfront_gather_backend_feat 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 @@ -2321,38 +2319,35 @@ static void blkfront_gather_backend_feat * * 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,