utils: Check if the parameter passed to countof() is actually an array type
This should avoid errors such as the one fixed with 118b2879.
This commit is contained in:
@@ -356,7 +356,8 @@ static inline void *memset_noop(void *s, int c, size_t n)
|
|||||||
/**
|
/**
|
||||||
* Get the number of elements in an array
|
* Get the number of elements in an array
|
||||||
*/
|
*/
|
||||||
#define countof(array) (sizeof(array)/sizeof(array[0]))
|
#define countof(array) (sizeof(array)/sizeof((array)[0]) \
|
||||||
|
+ BUILD_ASSERT_ARRAY(array))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ignore result of functions tagged with warn_unused_result attributes
|
* Ignore result of functions tagged with warn_unused_result attributes
|
||||||
|
|||||||
Reference in New Issue
Block a user