]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
hrtimers: Replace hrtimer_clock_to_base_table with switch-case
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Fri, 14 Feb 2025 13:43:33 +0000 (15:43 +0200)
committerThomas Gleixner <tglx@linutronix.de>
Tue, 18 Feb 2025 09:12:49 +0000 (10:12 +0100)
commit4441b976dfeff0d3579e8da3c0283300c618a553
tree2da6076d019b9801f65a65130263e746d3e478fa
parent2ea97b76d6712bfb0408e5b81ffd7bc4551d3153
hrtimers: Replace hrtimer_clock_to_base_table with switch-case

Clang and GCC complain about overlapped initialisers in the
hrtimer_clock_to_base_table definition. With `make W=1` and CONFIG_WERROR=y
(which is default nowadays) this breaks the build:

  CC      kernel/time/hrtimer.o
kernel/time/hrtimer.c:124:21: error: initializer overrides prior initialization of this subobject [-Werror,-Winitializer-overrides]
  124 |         [CLOCK_REALTIME]        = HRTIMER_BASE_REALTIME,

kernel/time/hrtimer.c:122:27: note: previous initialization is here
  122 |         [0 ... MAX_CLOCKS - 1]  = HRTIMER_MAX_CLOCK_BASES,

(and similar for CLOCK_MONOTONIC, CLOCK_BOOTTIME, and CLOCK_TAI).

hrtimer_clockid_to_base(), which uses the table, is only used in
__hrtimer_init(), which is not a hotpath.

Therefore replace the table lookup with a switch case in
hrtimer_clockid_to_base() to avoid this warning.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/all/20250214134424.3367619-1-andriy.shevchenko@linux.intel.com
kernel/time/hrtimer.c