public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] block/iocost: silence warning on 'last_period' potentially being unused
@ 2024-01-10 15:32 Jens Axboe
  2024-01-10 15:42 ` Johannes Thumshirn
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Jens Axboe @ 2024-01-10 15:32 UTC (permalink / raw)
  To: linux-block@vger.kernel.org; +Cc: Tejun Heo

If CONFIG_TRACEPOINTS isn't enabled, we assign this variable but then
never use it. This can cause the compiler to complain about that:

block/blk-iocost.c:1264:6: warning: variable 'last_period' set but not used [-Wunused-but-set-variable]
 1264 |         u64 last_period, cur_period;
      |             ^

Rather than add ifdefs to guard this, just mark it __maybe_unused.

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202401102335.GiWdeIo9-lkp@intel.com/
Signed-off-by: Jens Axboe <axboe@kernel.dk>

---

diff --git a/block/blk-iocost.c b/block/blk-iocost.c
index 089fcb9cfce3..c8beec6d7df0 100644
--- a/block/blk-iocost.c
+++ b/block/blk-iocost.c
@@ -1261,7 +1261,7 @@ static void weight_updated(struct ioc_gq *iocg, struct ioc_now *now)
 static bool iocg_activate(struct ioc_gq *iocg, struct ioc_now *now)
 {
 	struct ioc *ioc = iocg->ioc;
-	u64 last_period, cur_period;
+	u64 __maybe_unused last_period, cur_period;
 	u64 vtime, vtarget;
 	int i;
 
-- 
Jens Axboe


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] block/iocost: silence warning on 'last_period' potentially being unused
  2024-01-10 15:32 [PATCH] block/iocost: silence warning on 'last_period' potentially being unused Jens Axboe
@ 2024-01-10 15:42 ` Johannes Thumshirn
  2024-01-10 18:08 ` Tejun Heo
  2024-01-10 23:28 ` Chaitanya Kulkarni
  2 siblings, 0 replies; 4+ messages in thread
From: Johannes Thumshirn @ 2024-01-10 15:42 UTC (permalink / raw)
  To: Jens Axboe, linux-block@vger.kernel.org; +Cc: Tejun Heo

Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] block/iocost: silence warning on 'last_period' potentially being unused
  2024-01-10 15:32 [PATCH] block/iocost: silence warning on 'last_period' potentially being unused Jens Axboe
  2024-01-10 15:42 ` Johannes Thumshirn
@ 2024-01-10 18:08 ` Tejun Heo
  2024-01-10 23:28 ` Chaitanya Kulkarni
  2 siblings, 0 replies; 4+ messages in thread
From: Tejun Heo @ 2024-01-10 18:08 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-block@vger.kernel.org

On Wed, Jan 10, 2024 at 08:32:19AM -0700, Jens Axboe wrote:
> If CONFIG_TRACEPOINTS isn't enabled, we assign this variable but then
> never use it. This can cause the compiler to complain about that:
> 
> block/blk-iocost.c:1264:6: warning: variable 'last_period' set but not used [-Wunused-but-set-variable]
>  1264 |         u64 last_period, cur_period;
>       |             ^
> 
> Rather than add ifdefs to guard this, just mark it __maybe_unused.
> 
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202401102335.GiWdeIo9-lkp@intel.com/
> Signed-off-by: Jens Axboe <axboe@kernel.dk>

Acked-by: Tejun Heo <tj@kernel.org>

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] block/iocost: silence warning on 'last_period' potentially being unused
  2024-01-10 15:32 [PATCH] block/iocost: silence warning on 'last_period' potentially being unused Jens Axboe
  2024-01-10 15:42 ` Johannes Thumshirn
  2024-01-10 18:08 ` Tejun Heo
@ 2024-01-10 23:28 ` Chaitanya Kulkarni
  2 siblings, 0 replies; 4+ messages in thread
From: Chaitanya Kulkarni @ 2024-01-10 23:28 UTC (permalink / raw)
  To: Jens Axboe, linux-block@vger.kernel.org; +Cc: Tejun Heo

On 1/10/2024 7:32 AM, Jens Axboe wrote:
> If CONFIG_TRACEPOINTS isn't enabled, we assign this variable but then
> never use it. This can cause the compiler to complain about that:
> 
> block/blk-iocost.c:1264:6: warning: variable 'last_period' set but not used [-Wunused-but-set-variable]
>   1264 |         u64 last_period, cur_period;
>        |             ^
> 
> Rather than add ifdefs to guard this, just mark it __maybe_unused.
> 
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202401102335.GiWdeIo9-lkp@intel.com/
> Signed-off-by: Jens Axboe <axboe@kernel.dk>
> 
> ---
>

much cleaner than ifdef for sure...

Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>

-ck



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-01-10 23:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-10 15:32 [PATCH] block/iocost: silence warning on 'last_period' potentially being unused Jens Axboe
2024-01-10 15:42 ` Johannes Thumshirn
2024-01-10 18:08 ` Tejun Heo
2024-01-10 23:28 ` Chaitanya Kulkarni

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox