From b0d38f932fb349eb723511d8a84bc1c54e9cc844 Mon Sep 17 00:00:00 2001 From: Milan Broz Date: Thu, 31 Jul 2025 01:15:40 +0000 Subject: [PATCH] Add (ugly) wrorkaround for musl broken macro Nobody fixes this for years, there are multiple discussions. Let's just ignore it. --- lib/crypto_backend/crypto_cipher_kernel.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/crypto_backend/crypto_cipher_kernel.c b/lib/crypto_backend/crypto_cipher_kernel.c index e4ab924a..72918eb3 100644 --- a/lib/crypto_backend/crypto_cipher_kernel.c +++ b/lib/crypto_backend/crypto_cipher_kernel.c @@ -99,6 +99,20 @@ int crypt_cipher_init_kernel(struct crypt_cipher_kernel *ctx, const char *name, return _crypt_cipher_init(ctx, key, key_length, 0, &sa); } +/* musl has broken CMSG_NXTHDR macro in system headers */ +static inline struct cmsghdr *_CMSG_NXTHDR(struct msghdr* mhdr, struct cmsghdr* cmsg) +{ +#if !defined(__GLIBC__) && defined(__clang__) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wcast-align" +#pragma clang diagnostic ignored "-Wsign-compare" + return CMSG_NXTHDR(mhdr, cmsg); +#pragma clang diagnostic pop +#else + return CMSG_NXTHDR(mhdr, cmsg); +#endif +} + /* The in/out should be aligned to page boundary */ /* coverity[ -taint_source : arg-3 ] */ static int _crypt_cipher_crypt(struct crypt_cipher_kernel *ctx, @@ -146,7 +160,7 @@ static int _crypt_cipher_crypt(struct crypt_cipher_kernel *ctx, /* Set IV */ if (iv) { - header = CMSG_NXTHDR(&msg, header); + header = _CMSG_NXTHDR(&msg, header); if (!header) return -EINVAL;