Re: [PATCH v13 8/9] cpumask: Add initialiser to use cleanup helpers

From: Frederic Weisbecker
Date: Wed Sep 17 2025 - 12:45:15 EST


Le Wed, Sep 17, 2025 at 06:19:57PM +0200, Gabriele Monaco a écrit :
> From: Yury Norov <yury.norov@xxxxxxxxx>
>
> 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.
>
> Signed-off-by: Yury Norov <yury.norov@xxxxxxxxx>
> Signed-off-by: Gabriele Monaco <gmonaco@xxxxxxxxxx>

Reviewed-by: Frederic Weisbecker <frederic@xxxxxxxxxx>

--
Frederic Weisbecker
SUSE Labs