aboutsummaryrefslogtreecommitdiffstats
path: root/libkeccak.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--libkeccak.h30
1 files changed, 22 insertions, 8 deletions
diff --git a/libkeccak.h b/libkeccak.h
index d830ed8..42c9178 100644
--- a/libkeccak.h
+++ b/libkeccak.h
@@ -9,6 +9,14 @@
#include <string.h>
+#if defined(__clang__)
+# pragma clang diagnostic push
+# pragma clang diagnostic ignored "-Wdocumentation"
+# pragma clang diagnostic ignored "-Wunknown-attributes"
+#endif
+
+
+
/**
* Only include some C code if compiling with GCC.
*
@@ -808,7 +816,7 @@ struct libkeccak_hmac_state {
*/
unsigned char leftover;
- char __pad[sizeof(void *) / sizeof(char) - 1];
+ char __pad[sizeof(void *) - 1];
};
@@ -988,9 +996,11 @@ LIBKECCAK_GCC_ONLY(__attribute__((__nonnull__, __unused__, __warn_unused_result_
static inline struct libkeccak_hmac_state *
libkeccak_hmac_duplicate(const struct libkeccak_hmac_state *restrict src)
{
- struct libkeccak_hmac_state* restrict dest = malloc(sizeof(struct libkeccak_hmac_state));
- if (!dest || libkeccak_hmac_copy(dest, src))
- return libkeccak_hmac_free(dest), NULL;
+ struct libkeccak_hmac_state *restrict dest = malloc(sizeof(struct libkeccak_hmac_state));
+ if (!dest || libkeccak_hmac_copy(dest, src)) {
+ libkeccak_hmac_free(dest);
+ return NULL;
+ }
return dest;
}
@@ -1006,13 +1016,13 @@ static inline size_t
libkeccak_hmac_marshal(const struct libkeccak_hmac_state *restrict state, void *restrict data_)
{
unsigned char *restrict data = data_;
- size_t written = libkeccak_state_marshal(state ? &state->sponge : NULL, data);
+ size_t written = libkeccak_state_marshal(&state->sponge, data);
if (data) {
- data += written / sizeof(char);
+ data += written;
*(size_t *)data = state->key_length;
- data += sizeof(size_t) / sizeof(char);
+ data += sizeof(size_t);
memcpy(data, state->key_opad, (state->key_length + 7) >> 3);
- data += ((state->key_length + 7) >> 3) / sizeof(char);
+ data += (state->key_length + 7) >> 3;
data[0] = (unsigned char)!!state->key_ipad;
data[1] = state->leftover;
}
@@ -1094,4 +1104,8 @@ int libkeccak_hmac_digest(struct libkeccak_hmac_state *restrict state, const voi
#include "libkeccak-legacy.h"
+#if defined(__clang__)
+# pragma clang diagnostic pop
+#endif
+
#endif