Skip to content

Commit f7e30f0

Browse files
Matthias KaehlckeKAGA-KOKO
authored andcommitted
cpumask: Add helper cpumask_available()
With CONFIG_CPUMASK_OFFSTACK=y cpumask_var_t is a struct cpumask pointer, otherwise a struct cpumask array with a single element. Some code dealing with cpumasks needs to validate that a cpumask_var_t is not a NULL pointer when CONFIG_CPUMASK_OFFSTACK=y. This is typically done by performing the check always, regardless of the underlying type of cpumask_var_t. This works in both cases, however clang raises a warning like this when CONFIG_CPUMASK_OFFSTACK=n: kernel/irq/manage.c:839:28: error: address of array 'desc->irq_common_data.affinity' will always evaluate to 'true' [-Werror,-Wpointer-bool-conversion] Add the inline helper cpumask_available() which only performs the pointer check if CONFIG_CPUMASK_OFFSTACK=y. Signed-off-by: Matthias Kaehlcke <mka@chromium.org> Cc: Grant Grundler <grundler@chromium.org> Cc: Rusty Russell <rusty@rustcorp.com.au> Cc: Greg Hackmann <ghackmann@google.com> Cc: Michael Davidson <md@google.com> Cc: Andrew Morton <akpm@linux-foundation.org> Link: http://lkml.kernel.org/r/20170412182030.83657-1-mka@chromium.org Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
1 parent 45e5202 commit f7e30f0

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

include/linux/cpumask.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,11 @@ void alloc_bootmem_cpumask_var(cpumask_var_t *mask);
667667
void free_cpumask_var(cpumask_var_t mask);
668668
void free_bootmem_cpumask_var(cpumask_var_t mask);
669669

670+
static inline bool cpumask_available(cpumask_var_t mask)
671+
{
672+
return mask != NULL;
673+
}
674+
670675
#else
671676
typedef struct cpumask cpumask_var_t[1];
672677

@@ -708,6 +713,11 @@ static inline void free_cpumask_var(cpumask_var_t mask)
708713
static inline void free_bootmem_cpumask_var(cpumask_var_t mask)
709714
{
710715
}
716+
717+
static inline bool cpumask_available(cpumask_var_t mask)
718+
{
719+
return true;
720+
}
711721
#endif /* CONFIG_CPUMASK_OFFSTACK */
712722

713723
/* It's common to want to use cpu_all_mask in struct member initializers,

0 commit comments

Comments
 (0)