aboutsummaryrefslogtreecommitdiffstats
path: root/libkeccak_state_unmarshal.c
diff options
context:
space:
mode:
Diffstat (limited to 'libkeccak_state_unmarshal.c')
-rw-r--r--libkeccak_state_unmarshal.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/libkeccak_state_unmarshal.c b/libkeccak_state_unmarshal.c
index e46db54..4e0df28 100644
--- a/libkeccak_state_unmarshal.c
+++ b/libkeccak_state_unmarshal.c
@@ -2,21 +2,26 @@
#include "common.h"
+#if defined(__clang__)
+# pragma clang diagnostic ignored "-Wcast-align"
+#endif
+
+
/**
* Unmarshal a `struct libkeccak_state` from a buffer
*
* @param state The slot for the unmarshalled state, must not be
* initialised (memory leak otherwise), can be `NULL`
- * @param data The input buffer
+ * @param data_ The input buffer
* @return The number of bytes read from `data`, 0 on error
*/
size_t
libkeccak_state_unmarshal(struct libkeccak_state *restrict state, const void *restrict data_)
{
-#define get(type, var) state->var = *((const type *)data), data += sizeof(type) / sizeof(char)
+#define get(type, var) state->var = *((const type *)data), data += sizeof(type)
const unsigned char *restrict data = data_;
if (!state) {
- data += (7 * sizeof(long int) + 26 * sizeof(int64_t)) / sizeof(char);
+ data += (7 * sizeof(long int) + 26 * sizeof(int64_t));
return sizeof(struct libkeccak_state) - sizeof(char *) + *(const size_t *)data * sizeof(char);
}
get(long int, r);
@@ -28,7 +33,7 @@ libkeccak_state_unmarshal(struct libkeccak_state *restrict state, const void *re
get(long int, l);
get(long int, nr);
memcpy(state->S, data, sizeof(state->S));
- data += sizeof(state->S) / sizeof(char);
+ data += sizeof(state->S);
get(size_t, mptr);
get(size_t, mlen);
state->M = malloc(state->mptr * sizeof(char));