]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Some more alignment fixes
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 12 Aug 2019 20:44:22 +0000 (21:44 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 12 Aug 2019 20:44:22 +0000 (21:44 +0100)
src/libcryptobox/base64/ref.c
src/libstat/tokenizers/tokenizers.c

index c7cefd7612c2fe4e36eddacbf6563c04d1964d8e..68889b90eb52e99327925c18d115d9b0403e08a4 100644 (file)
@@ -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++;
 
index 12b860b67057a6f18be3b68c3f668631a310b073..ea3c84c67c1ba24d654e7d52ddab6fd03605f21b 100644 (file)
@@ -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 */