Skip to contentSkip to conversation

block: avoid -Wunused-but-set-parameter warning

PATCH New Arnd Bergmann 1 participant 1 message Mar 23, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 block: avoid -Wunused-but-set-parameter warning

From: Arnd Bergmann <[email protected]>

Building with 'make W=1' shows a warning for one function parameter that is only set but not used in some configurations:

kernel/trace/blktrace.c: In function '__trace_note_message':
kernel/trace/blktrace.c:148:63: error: parameter 'blkcg' set but not used [-Werror=unused-but-set-parameter]
148 | void __trace_note_message(struct blk_trace *bt, struct blkcg *blkcg,

Move the assignment into the #ifdef block that contains the only use to clarify how it's used and avoid the warning.

Apparently this is the only -Wunused-but-set-parameter warning in the kernel as of v5.12, after similar cleanups done by others. It may be time to turn it on globally.

Fixes 35fe6d763229 ("block: use standard blktrace API to output cgroup info for debug notes")
---
 kernel/trace/blktrace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/blktrace.c +1 -1
index c221e4c3f625..f9314351a7e2 100644
@@ -170,9 +170,9 @@ void __trace_note_message(struct blk_trace *bt, struct blkcg *blkcg,
 	n = vscnprintf(buf, BLK_TN_MAX_MSG, fmt, args);
 	va_end(args);
 
+#ifdef CONFIG_BLK_CGROUP
 	if (!(blk_tracer_flags.val & TRACE_BLK_OPT_CGROUP))
 		blkcg = NULL;
-#ifdef CONFIG_BLK_CGROUP
 	trace_note(bt, current->pid, BLK_TN_MESSAGE, buf, n,
 		   blkcg ? cgroup_id(blkcg->css.cgroup) : 1);
 #else
Signature · 1 line
2.29.2