From d68b8b189c2671c261d0e49b02eaf2b86b5947fa Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Fri, 7 Feb 2020 15:46:59 +0100 Subject: [PATCH] curve25519: squelch warnings on clang These are generic helper functions we don't want to move into the actual implementations, so that it's easy to keep parity with the kernel code. Signed-off-by: Jason A. Donenfeld --- src/curve25519.c | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/src/curve25519.c b/src/curve25519.c index 7d3fd15..1739a9e 100644 --- a/src/curve25519.c +++ b/src/curve25519.c @@ -39,23 +39,9 @@ typedef int64_t s64; #define le32_to_cpup(a) (*(a)) #define cpu_to_le64(a) (a) #endif -static inline __le32 get_unaligned_le32(const u8 *a) -{ - __le32 l; - __builtin_memcpy(&l, a, sizeof(l)); - return le32_to_cpup(&l); -} -static inline __le64 get_unaligned_le64(const u8 *a) -{ - __le64 l; - __builtin_memcpy(&l, a, sizeof(l)); - return le64_to_cpup(&l); -} -static inline void put_unaligned_le64(u64 s, u8 *d) -{ - __le64 l = cpu_to_le64(s); - __builtin_memcpy(d, &l, sizeof(l)); -} +#ifndef __unused +#define __unused __attribute__((unused)) +#endif #ifndef __always_inline #define __always_inline __inline __attribute__((__always_inline__)) #endif @@ -69,6 +55,24 @@ static inline void put_unaligned_le64(u64 s, u8 *d) #define __force #endif +static __always_inline __unused __le32 get_unaligned_le32(const u8 *a) +{ + __le32 l; + __builtin_memcpy(&l, a, sizeof(l)); + return le32_to_cpup(&l); +} +static __always_inline __unused __le64 get_unaligned_le64(const u8 *a) +{ + __le64 l; + __builtin_memcpy(&l, a, sizeof(l)); + return le64_to_cpup(&l); +} +static __always_inline __unused void put_unaligned_le64(u64 s, u8 *d) +{ + __le64 l = cpu_to_le64(s); + __builtin_memcpy(d, &l, sizeof(l)); +} + static noinline void memzero_explicit(void *s, size_t count) { memset(s, 0, count);