[build] Fix build failures with random versions of gcc

For unknown reasons, miscellaneous versions of gcc seem to struggle
with the static assertions used to ensure the correct layout of the
GCM structures.

Adjust the assertions to use offsetof() rather than direct pointer
comparison, on the basis that offsetof() must be a compile-time
constant value.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2024-03-27 14:28:47 +00:00
parent 9bbe77669c
commit 37850e0e85
2 changed files with 18 additions and 15 deletions

View File

@@ -89,10 +89,9 @@ static int _gcm_name ## _setkey ( void *ctx, const void *key, \
size_t keylen ) { \
struct _gcm_name ## _context *context = ctx; \
build_assert ( _blocksize == sizeof ( context->gcm.key ) ); \
build_assert ( ( ( void * ) &context->gcm ) == \
( ( void * ) context ) ); \
build_assert ( ( ( void * ) &context->raw ) == \
( ( void * ) context->gcm.raw_ctx ) ); \
build_assert ( offsetof ( typeof ( *context ), gcm ) == 0 ); \
build_assert ( offsetof ( typeof ( *context ), raw ) == \
offsetof ( typeof ( *context ), gcm.raw_ctx ) ); \
return gcm_setkey ( &context->gcm, key, keylen, &_raw_cipher ); \
} \
static void _gcm_name ## _setiv ( void *ctx, const void *iv, \