[PATCH v1] sched/topology: Make compiler happy about unused constant definitions

From: Andy Shevchenko
Date: Mon Aug 24 2020 - 11:41:41 EST


Compilation of almost each file ends up with

In file included from .../include/linux/energy_model.h:10,
from .../include/linux/device.h:16,
from .../drivers/spi/spi.c:8:
.../include/linux/sched/topology.h:30:27: warning: ‘SD_DEGENERATE_GROUPS_MASK’ defined but not used [-Wunused-const-variable=]
30 | static const unsigned int SD_DEGENERATE_GROUPS_MASK =
| ^~~~~~~~~~~~~~~~~~~~~~~~~
...

Make compiler happy by annotating the static constants with __maybwe_unused.

Fixes: 4ee4ea443a5d ("sched/topology: Introduce SD metaflag for flags needing > 1 groups")
Cc: Valentin Schneider <valentin.schneider@xxxxxxx>
Cc: Dietmar Eggemann <dietmar.eggemann@xxxxxxx>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
---
include/linux/sched/topology.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/sched/topology.h b/include/linux/sched/topology.h
index 2d59ca77103e..ec440b67599c 100644
--- a/include/linux/sched/topology.h
+++ b/include/linux/sched/topology.h
@@ -27,14 +27,14 @@ enum {

/* Generate a mask of SD flags with the SDF_NEEDS_GROUPS metaflag */
#define SD_FLAG(name, mflags) (name * !!((mflags) & SDF_NEEDS_GROUPS)) |
-static const unsigned int SD_DEGENERATE_GROUPS_MASK =
+static __maybe_unused const unsigned int SD_DEGENERATE_GROUPS_MASK =
#include <linux/sched/sd_flags.h>
0;
#undef SD_FLAG

#ifdef CONFIG_SCHED_DEBUG
#define SD_FLAG(_name, mflags) [__##_name] = { .meta_flags = mflags, .name = #_name },
-static const struct {
+static __maybe_unused const struct {
unsigned int meta_flags;
char *name;
} sd_flag_debug[] = {
--
2.28.0