diff options
author | Martin Willi <martin@revosec.ch> | 2014-07-04 14:37:58 +0200 |
---|---|---|
committer | Martin Willi <martin@revosec.ch> | 2014-08-25 09:48:53 +0200 |
commit | 11bf11c1f55402cc08deeb53ee94387afc4a4525 (patch) | |
tree | 7d5d5bd459086c88c1d0564c69152d7dd7d55c35 /src | |
parent | bb6be261974788d971226d7508bcbc49af86e96e (diff) | |
download | strongswan-11bf11c1f55402cc08deeb53ee94387afc4a4525.tar.bz2 strongswan-11bf11c1f55402cc08deeb53ee94387afc4a4525.tar.xz |
utils: Check if the parameter passed to countof() is actually an array type
This should avoid errors such as the one fixed with 118b2879.
Diffstat (limited to 'src')
-rw-r--r-- | src/libstrongswan/utils/utils.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/libstrongswan/utils/utils.h b/src/libstrongswan/utils/utils.h index cb60c6e3e..da253cc35 100644 --- a/src/libstrongswan/utils/utils.h +++ b/src/libstrongswan/utils/utils.h @@ -356,7 +356,8 @@ static inline void *memset_noop(void *s, int c, size_t n) /** * 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 |