diff options
author | Dmitry V. Levin <ldv@altlinux.org> | 2020-03-19 18:40:16 +0000 |
---|---|---|
committer | Dmitry V. Levin <ldv@altlinux.org> | 2020-03-19 18:40:16 +0000 |
commit | f6c60926adc9fa08feaeb696ffa5bfbac7c8c9e8 (patch) | |
tree | e6a3393a6eeb6b844e858cb8d8ad20e867297e39 /modules/pam_namespace | |
parent | 2dc4cc4dcecf1ba299de1bd1eb40d8f9d9d0e054 (diff) | |
download | pam-f6c60926adc9fa08feaeb696ffa5bfbac7c8c9e8.tar.gz pam-f6c60926adc9fa08feaeb696ffa5bfbac7c8c9e8.tar.bz2 pam-f6c60926adc9fa08feaeb696ffa5bfbac7c8c9e8.zip |
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.
Diffstat (limited to 'modules/pam_namespace')
-rw-r--r-- | modules/pam_namespace/md5.c | 6 | ||||
-rw-r--r-- | modules/pam_namespace/md5.h | 4 |
2 files changed, 7 insertions, 3 deletions
diff --git a/modules/pam_namespace/md5.c b/modules/pam_namespace/md5.c index dc95ab14..b9a7f084 100644 --- a/modules/pam_namespace/md5.c +++ b/modules/pam_namespace/md5.c @@ -26,12 +26,14 @@ #if defined(__i386) || defined(__i386__) || defined(__x86_64) || defined(__x86_64__) #define byteReverse(buf, len) /* Nothing */ #else -static void byteReverse(unsigned char *buf, unsigned longs); +typedef unsigned char PAM_ATTRIBUTE_ALIGNED(4) uint8_aligned; + +static void byteReverse(uint8_aligned *buf, unsigned longs); /* * Note: this code is harmless on little-endian machines. */ -static void byteReverse(unsigned char *buf, unsigned longs) +static void byteReverse(uint8_aligned *buf, unsigned longs) { uint32 t; do { diff --git a/modules/pam_namespace/md5.h b/modules/pam_namespace/md5.h index 73f85833..bded3302 100644 --- a/modules/pam_namespace/md5.h +++ b/modules/pam_namespace/md5.h @@ -2,12 +2,14 @@ #ifndef MD5_H #define MD5_H +#include "pam_cc_compat.h" + typedef unsigned int uint32; struct MD5Context { uint32 buf[4]; uint32 bits[2]; - unsigned char in[64]; + unsigned char in[64] PAM_ATTRIBUTE_ALIGNED(4); }; #define MD5_DIGEST_LENGTH 16 |