mirror of
https://github.com/neovim/neovim.git
synced 2025-10-07 02:16:31 +00:00
PVS/V1051: Ignore "modulo by 1" warning for ARRAY_SIZE. (#14943)
The warning is triggered by the second division when arr is a char array since sizeof(char) is 1. A modulo by 1 may normally indicate a logic error, but in this case it's intended.
This commit is contained in:
@@ -133,6 +133,8 @@
|
|||||||
/// error. A mechanism to detect many (though not all) of those errors at
|
/// error. A mechanism to detect many (though not all) of those errors at
|
||||||
/// compile time is implemented. It works by the second division producing
|
/// compile time is implemented. It works by the second division producing
|
||||||
/// a division by zero in those cases (-Wdiv-by-zero in GCC).
|
/// a division by zero in those cases (-Wdiv-by-zero in GCC).
|
||||||
|
///
|
||||||
|
/// -V:ARRAY_SIZE:1063
|
||||||
#define ARRAY_SIZE(arr) \
|
#define ARRAY_SIZE(arr) \
|
||||||
((sizeof(arr)/sizeof((arr)[0])) \
|
((sizeof(arr)/sizeof((arr)[0])) \
|
||||||
/ ((size_t)(!(sizeof(arr) % sizeof((arr)[0])))))
|
/ ((size_t)(!(sizeof(arr) % sizeof((arr)[0])))))
|
||||||
|
Reference in New Issue
Block a user