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>
This commit is contained in:
Leah Rowe
2026-03-13 01:26:42 +00:00
parent 681f580053
commit a049f2df39
+9
View File
@@ -63,6 +63,7 @@
#endif
#include <errno.h>
#include <limits.h>
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
@@ -257,6 +258,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)
{