diff options
| author | Leah Rowe <leah@libreboot.org> | 2026-03-13 01:26:42 +0000 |
|---|---|---|
| committer | Leah Rowe <leah@libreboot.org> | 2026-03-13 01:26:42 +0000 |
| commit | ee9045b8074d28e5d9de110a3114f74f409c1b2d (patch) | |
| tree | 97752ea61a88b5307ccceed2e0b87b400aa82596 | |
| parent | 4e48b173ae70df0064650ea626152c9007175001 (diff) | |
util/spkmodem-decode: static asserts
assert integer sizes, important in this program because
we make several implicit assumptions about word sizes,
and integers need to be of a certain size.
Signed-off-by: Leah Rowe <leah@libreboot.org>
| -rw-r--r-- | util/spkmodem_decode/spkmodem-decode.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/util/spkmodem_decode/spkmodem-decode.c b/util/spkmodem_decode/spkmodem-decode.c index a5283e51..4e209bf8 100644 --- a/util/spkmodem_decode/spkmodem-decode.c +++ b/util/spkmodem_decode/spkmodem-decode.c @@ -63,6 +63,7 @@ #endif #include <errno.h> +#include <limits.h> #include <stdio.h> #include <stdarg.h> #include <stdlib.h> @@ -253,6 +254,14 @@ extern int optind; extern int opterr; extern int optopt; +typedef char static_assert_char_is_8_bits[(CHAR_BIT == 8) ? 1 : -1]; +typedef char static_assert_char_is_1[(sizeof(char) == 1) ? 1 : -1]; +typedef char static_assert_short[(sizeof(short) == 2) ? 1 : -1]; +typedef char static_assert_int_is_4[(sizeof(int) >= 4) ? 1 : -1]; +typedef char static_assert_twos_complement[ + ((-1 & 3) == 3) ? 1 : -1 +]; + int main(int argc, char **argv) { |
