From e900e3fce155c8ad08c69b3be0668e25262b15d1 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Mon, 12 Aug 2019 21:44:22 +0100 Subject: [PATCH] [Minor] Some more alignment fixes --- src/libcryptobox/base64/ref.c | 10 ++++------ src/libstat/tokenizers/tokenizers.c | 4 ---- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/libcryptobox/base64/ref.c b/src/libcryptobox/base64/ref.c index c7cefd761..68889b90e 100644 --- a/src/libcryptobox/base64/ref.c +++ b/src/libcryptobox/base64/ref.c @@ -35,7 +35,6 @@ extern const uint8_t base64_table_dec[256]; #define INNER_LOOP_64 do { \ uint64_t str, res, dec; \ bool aligned = rspamd_is_aligned_as(c, str); \ - bool oaligned = rspamd_is_aligned_as(o, res); \ while (inlen >= 13) { \ if (aligned) { str = *(uint64_t *)c; } else {memcpy(&str, c, sizeof(str)); } \ str = GUINT64_TO_BE(str); \ @@ -72,7 +71,7 @@ extern const uint8_t base64_table_dec[256]; } \ res |= dec << 16; \ res = GUINT64_FROM_BE(res); \ - if (oaligned) {*(uint64_t *)o = res;} else {memcpy(o, &res, sizeof(res));} \ + memcpy(o, &res, sizeof(res)); \ c += 8; \ o += 6; \ outl += 6; \ @@ -83,7 +82,6 @@ extern const uint8_t base64_table_dec[256]; #define INNER_LOOP_32 do { \ uint32_t str, res, dec; \ bool aligned = rspamd_is_aligned_as(c, str); \ - bool oaligned = rspamd_is_aligned_as(o, res); \ while (inlen >= 8) { \ if (aligned) { str = *(uint32_t *)c; } else {memcpy(&str, c, sizeof(str)); } \ str = GUINT32_TO_BE(str); \ @@ -104,7 +102,7 @@ extern const uint8_t base64_table_dec[256]; } \ res |= dec << 8; \ res = GUINT32_FROM_BE(res); \ - if (oaligned) {*(uint32_t *)o = res;} else {memcpy(o, &res, sizeof(res));} \ + memcpy(o, &res, sizeof(res)); \ c += 4; \ o += 3; \ outl += 3; \ @@ -142,7 +140,7 @@ repeat: ret = 0; break; } - carry = q << 2; + carry = (uint8_t)(q << 2); leftover++; case 1: @@ -186,7 +184,7 @@ repeat: break; } *o++ = carry | (q >> 2); - carry = q << 6; + carry = (uint8_t)(q << 6); leftover++; outl++; diff --git a/src/libstat/tokenizers/tokenizers.c b/src/libstat/tokenizers/tokenizers.c index 12b860b67..ea3c84c67 100644 --- a/src/libstat/tokenizers/tokenizers.c +++ b/src/libstat/tokenizers/tokenizers.c @@ -173,13 +173,9 @@ rspamd_tokenize_check_limit (gboolean decay, if (!decay) { if (token->original.len >= sizeof (guint64)) { -#ifdef _MUM_UNALIGNED_ACCESS - *hv = mum_hash_step (*hv, *(guint64 *)token->original.begin); -#else guint64 tmp; memcpy (&tmp, token->original.begin, sizeof (tmp)); *hv = mum_hash_step (*hv, tmp); -#endif } /* Check for decay */ -- 2.39.5