mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-07-11 14:02:52 +02:00
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:
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user