From f6c60926adc9fa08feaeb696ffa5bfbac7c8c9e8 Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Thu, 19 Mar 2020 18:40:16 +0000 Subject: Fix most of clang -Wcast-align compilation warnings Unlike gcc, clang is not smart enough to infer the alignment of structure fields, so add some alignment hints to the code. * libpam/include/pam_cc_compat.h (PAM_ATTRIBUTE_ALIGNED): New macro. * modules/pam_namespace/md5.h: Include "pam_cc_compat.h". (struct MD5Context): Add PAM_ATTRIBUTE_ALIGNED to "in" field. * modules/pam_namespace/md5.c [!(__i386__ || __x86_64__)] (uint8_aligned): New type. [!(__i386__ || __x86_64__)] (byteReverse): Use it instead of unsigned char. * modules/pam_timestamp/sha1.h: Include "pam_cc_compat.h". (struct sha1_context): Add PAM_ATTRIBUTE_ALIGNED to pending field. * modules/pam_unix/md5.h: Include "pam_cc_compat.h". (struct MD5Context): Add PAM_ATTRIBUTE_ALIGNED to "in" field. * modules/pam_unix/md5.c [!HIGHFIRST] (uint8_aligned): New type. [!HIGHFIRST] (byteReverse): Use it instead of unsigned char. --- modules/pam_timestamp/sha1.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'modules/pam_timestamp/sha1.h') diff --git a/modules/pam_timestamp/sha1.h b/modules/pam_timestamp/sha1.h index a445e4e6..a1c38917 100644 --- a/modules/pam_timestamp/sha1.h +++ b/modules/pam_timestamp/sha1.h @@ -40,12 +40,13 @@ #include #include +#include "pam_cc_compat.h" #define SHA1_BLOCK_SIZE 64 struct sha1_context { size_t count; - unsigned char pending[SHA1_BLOCK_SIZE]; + unsigned char pending[SHA1_BLOCK_SIZE] PAM_ATTRIBUTE_ALIGNED(4); uint32_t counts[2]; size_t pending_count; uint32_t a, b, c, d, e; -- cgit v1.2.3