From patchwork Thu Apr 20 00:09:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 9689221 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 76925602C9 for ; Thu, 20 Apr 2017 00:09:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 68B0C28387 for ; Thu, 20 Apr 2017 00:09:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5D57028447; Thu, 20 Apr 2017 00:09:33 +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=-6.4 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4F8D328387 for ; Thu, 20 Apr 2017 00:09:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S968931AbdDTAJb (ORCPT ); Wed, 19 Apr 2017 20:09:31 -0400 Received: from mail-io0-f170.google.com ([209.85.223.170]:33835 "EHLO mail-io0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S968937AbdDTAJb (ORCPT ); Wed, 19 Apr 2017 20:09:31 -0400 Received: by mail-io0-f170.google.com with SMTP id a103so44686382ioj.1 for ; Wed, 19 Apr 2017 17:09:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=e3nCnWsLDYJTfFvqvfFMyKaDam0FN/1179q7S9DdpQ4=; b=pjmvaDP2NlyNRNjMMVzKjUINt29ru7MziWxhnHD4HUhq/4kgwv+v3wU3SVbapTqAUB 0KShI2Tyl0O847gInkh9sAhaXmePG2UnQwRzqQvM5B4zKcS1gfjt+9HWfkCDH72id6wb 6KfE90Q/MJ3uAUky9rOFJwa8cxZkrvbV8tdeTVgPEEBuT1Vb9dZvLAj1cH6j4ke4CI7L xrqi6j5N4tJaJmR1oVmLtzMbaPFkdzmIN0k6AZcURRXHwLXDyctiLMYkU31FyhPyBJZa kY0wD05Gm0uOndG4IigNkShK6zsD/XMlddjz/QwmK5K9K6nTuZNXFH88XpCGVUFCd6Mj qLgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=e3nCnWsLDYJTfFvqvfFMyKaDam0FN/1179q7S9DdpQ4=; b=TT1eek8F7Yr4D2DbhHUTm/obP0+NUtsKp04yXWuy5o4WAZf8AU/OXM3KSy0LO/w9Lf sxdZhzw5g/l18e3WF4nAqeYIlCXAFftzAw98niDZjaFgBKC7k8YqxiZc1u67dNzMstlp 0t0/jO8jnMXjxfMzfJPiDvibZeBgwlJMwzmMs3U5/l1GtOTHytkCt3k4qfthUlWAOcS/ LC9SGEwC3to8X773fWtZD4k5hgI+0kdq340d4tMMPYygPAmNuMvkkTA0WfUFgdY5c+I4 J/G3BdPM9psMlQxCD7UgPRdx1J7EDxhfocU1eoYcQfEflQXvtZjitKAEGjnhJcsI/J3E 83QA== X-Gm-Message-State: AN3rC/4Trl0oCi1iCmEbmo5A+C1petGpZRrRfyGoSjszVIPQ+0dAvHS7 Qy9K58tN90eHQoeO9bA= X-Received: by 10.98.202.80 with SMTP id n77mr5562178pfg.158.1492646969002; Wed, 19 Apr 2017 17:09:29 -0700 (PDT) Received: from [192.168.1.176] (66.29.164.166.static.utbb.net. [66.29.164.166]) by smtp.gmail.com with ESMTPSA id e131sm6529574pfg.10.2017.04.19.17.09.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Apr 2017 17:09:28 -0700 (PDT) Subject: Re: [PATCH] blk-throttle: Suppress a compiler warning To: Bart Van Assche References: <20170419235504.5463-1-bart.vanassche@sandisk.com> Cc: linux-block@vger.kernel.org, Shaohua Li From: Jens Axboe Message-ID: <089b9e20-c20d-1d10-f230-4aebbb5f03ee@kernel.dk> Date: Wed, 19 Apr 2017 18:09:27 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <20170419235504.5463-1-bart.vanassche@sandisk.com> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On 04/19/2017 05:55 PM, Bart Van Assche wrote: > Avoid that the following warning is reported when building with > W=1 and with CONFIG_BLK_DEV_THROTTLING_LOW=n: > > block/blk-throttle.c: In function ‘blk_throtl_bio’: > block/blk-throttle.c:2042:6: warning: variable ‘ret’ set but not used [-Wunused-but-set-variable] > int ret; > ^~~ > > Signed-off-by: Bart Van Assche > Cc: Shaohua Li > --- > block/blk-throttle.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/block/blk-throttle.c b/block/blk-throttle.c > index c82bf9b1fe72..9081ed9a5345 100644 > --- a/block/blk-throttle.c > +++ b/block/blk-throttle.c > @@ -2059,6 +2059,10 @@ bool blk_throtl_bio(struct request_queue *q, struct blkcg_gq *blkg, > if (ret == 0 || ret == -EBUSY) > bio->bi_cg_private = tg; > blk_stat_set_issue(&bio->bi_issue_stat, bio_sectors(bio)); > +#else > + /* Avoid that the compiler complains about not using ret */ > + if (ret) { > + } > #endif Ugh, that may get rid of the warning, but it does not help on the readability or the ifdefs. How about something like the below? Naming could probably be improved... diff --git a/block/blk-throttle.c b/block/blk-throttle.c index c82bf9b1fe72..b78db2e5fdff 100644 --- a/block/blk-throttle.c +++ b/block/blk-throttle.c @@ -2030,6 +2030,20 @@ static inline void throtl_update_latency_buckets(struct throtl_data *td) } #endif +static void blk_throtl_assoc_bio(struct throtl_grp *tg, struct bio *bio) +{ +#ifdef CONFIG_BLK_DEV_THROTTLING_LOW + int ret; + + ret = bio_associate_current(bio); + if (ret == 0 || ret == -EBUSY) + bio->bi_cg_private = tg; + blk_stat_set_issue(&bio->bi_issue_stat, bio_sectors(bio)); +#else + bio_associate_current(bio); +#endif +} + bool blk_throtl_bio(struct request_queue *q, struct blkcg_gq *blkg, struct bio *bio) { @@ -2039,7 +2053,6 @@ bool blk_throtl_bio(struct request_queue *q, struct blkcg_gq *blkg, bool rw = bio_data_dir(bio); bool throttled = false; struct throtl_data *td = tg->td; - int ret; WARN_ON_ONCE(!rcu_read_lock_held()); @@ -2054,12 +2067,7 @@ bool blk_throtl_bio(struct request_queue *q, struct blkcg_gq *blkg, if (unlikely(blk_queue_bypass(q))) goto out_unlock; - ret = bio_associate_current(bio); -#ifdef CONFIG_BLK_DEV_THROTTLING_LOW - if (ret == 0 || ret == -EBUSY) - bio->bi_cg_private = tg; - blk_stat_set_issue(&bio->bi_issue_stat, bio_sectors(bio)); -#endif + blk_throtl_assoc_bio(tg, bio); blk_throtl_update_idletime(tg); sq = &tg->service_queue;