v4.4.1: Harden C 99 API with `static n` Array Arguments
·
0 commits
to 039c4b4930bbec330682f4efa2316da4d2c651e7
since this release
Added sz_at_least(n) macro for C99's static array parameter syntax, enabling compile-time bounds checking on fixed-size array arguments. In C mode, Clang will now warn when passing undersized arrays to annotated functions. The macro expands to nothing in C++ for compatibility.
// Compiler can now warn if the digest buffer is smaller than 32 bytes
void sz_sha256_state_digest(..., sz_u8_t digest[sz_at_least(32)]);
// Lookup tables must be at least 256 bytes
void sz_lookup(..., char const lut[sz_at_least(256)]);See LWN.net article for background on this feature and its use in the Linux kernel.