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:
dundargoc
2021-07-03 16:50:05 +02:00
committed by GitHub
parent 05330ba508
commit 70223babb0

View File

@@ -133,6 +133,8 @@
/// error. A mechanism to detect many (though not all) of those errors at
/// compile time is implemented. It works by the second division producing
/// a division by zero in those cases (-Wdiv-by-zero in GCC).
///
/// -V:ARRAY_SIZE:1063
#define ARRAY_SIZE(arr) \
((sizeof(arr)/sizeof((arr)[0])) \
/ ((size_t)(!(sizeof(arr) % sizeof((arr)[0])))))