[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH] cpumask: fix integer type in cpumask_first
Hi Stefano, On 29/09/2023 00:32, Stefano Stabellini wrote: nr_cpu_ids is unsigned int, but find_first_bit returns unsigned long (at least on arm). find_* are meant to be used by common code. So I think the first step is to correct the return type so it is consistent across all architectures. I don't have a strong opinion on whether they should all return 'unsigned long'. Then we can discuss if the MISRA rule is still violated. Use the larger type for min_t to avoid larger-to-smaller type assignments. This address 141 MISRA C 10.3 violations. I find interesting you are saying this given that... Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxx> --- diff --git a/xen/include/xen/cpumask.h b/xen/include/xen/cpumask.h index 9826707909..a6ed6a28e8 100644 --- a/xen/include/xen/cpumask.h +++ b/xen/include/xen/cpumask.h @@ -208,7 +208,7 @@ static inline void cpumask_copy(cpumask_t *dstp, const cpumask_t *srcp)static inline int cpumask_first(const cpumask_t *srcp){ - return min_t(int, nr_cpu_ids, find_first_bit(srcp->bits, nr_cpu_ids)); + return min_t(unsigned long, nr_cpu_ids, find_first_bit(srcp->bits, nr_cpu_ids)); ... cpumask_first() is return 'int'. So rather than fixing it, you seem to have just moved the violation. }static inline int cpumask_next(int n, const cpumask_t *srcp) Cheers, -- Julien Grall
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |