Skip to contentSkip to conversation

block/iocost: silence warning on 'last_period' potentially being unused

PATCH In review Jens Axboe 4 participants 4 messages Jan 10, 2024

Subsystems (2)
lore
Share & tools
lore

Jens Axboe

author maintainer
#0 lore raw

PATCH 1/1 block/iocost: silence warning on 'last_period' potentially being unused

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.

---

block/blk-iocost.c +1 -1
index 089fcb9cfce3..c8beec6d7df0 100644
@@ -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;
 
Signature · 1 line
Jens Axboe
maintainer Acked-by on v1 1/1
#2 lore raw
In reply to Jens Axboe
Quoted 7 lines · Jens Axboe

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;
| ^

Quoted 5 lines

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

Thanks.

Signature · 1 line
tejun
Reviewed-by on v1 1/1
#3 lore raw
In reply to Jens Axboe
Quoted 7 lines · Jens Axboe

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;
| ^

Quoted 8 lines

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

---

much cleaner than ifdef for sure...

-ck