]> Gentwo Git Trees - linux/.git/commit
cpumask: Add initialiser to use cleanup helpers
authorYury Norov <yury.norov@gmail.com>
Thu, 20 Nov 2025 14:56:52 +0000 (15:56 +0100)
committerThomas Gleixner <tglx@linutronix.de>
Thu, 20 Nov 2025 19:17:32 +0000 (20:17 +0100)
commitb56651007fc018effe695a68d48caa6970b23094
tree765715a0e8156a0b02e913d45a9f1acf0478dfc3
parent185bccc79797d71477e672a1b2a2b7d0325044e7
cpumask: Add initialiser to use cleanup helpers

Now we can simplify a code that allocates cpumasks for local needs.

Automatic variables have to be initialized at declaration, or at least
before any possibility for the logic to return, so that compiler
wouldn't try to call an associate destructor function on a random stack
number.

Because cpumask_var_t, depending on the CPUMASK_OFFSTACK config, is
either a pointer or an array, we have to have a macro for initialization.

So define a CPUMASK_VAR_NULL macro, which allows to init struct cpumask
pointer with NULL when CPUMASK_OFFSTACK is enabled, and effectively a
no-op when CPUMASK_OFFSTACK is disabled (initialisation optimised out
with -O2).

Signed-off-by: Yury Norov <yury.norov@gmail.com>
Signed-off-by: Gabriele Monaco <gmonaco@redhat.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Frederic Weisbecker <frederic@kernel.org>
Link: https://patch.msgid.link/20251120145653.296659-7-gmonaco@redhat.com
include/linux/cpumask.h