From 191aed977f6c5eae17697065300b0fc2cd434f8d Mon Sep 17 00:00:00 2001 From: "John M. Schanck" Date: Tue, 1 Sep 2020 15:56:45 -0400 Subject: [PATCH] NTRU Prime: more compiler warnings --- crypto_kem/ntrulpr653/avx2/crypto_decode_653x1541.c | 4 ---- crypto_kem/ntrulpr653/avx2/crypto_decode_653x3.c | 2 +- crypto_kem/ntrulpr653/clean/crypto_decode_653x3.c | 10 +++++----- crypto_kem/ntrulpr761/avx2/crypto_decode_761x1531.c | 4 ---- crypto_kem/ntrulpr761/avx2/crypto_decode_761x3.c | 2 +- crypto_kem/ntrulpr761/clean/crypto_decode_761x3.c | 10 +++++----- crypto_kem/ntrulpr857/avx2/crypto_decode_857x1723.c | 4 ---- crypto_kem/ntrulpr857/avx2/crypto_decode_857x3.c | 2 +- crypto_kem/ntrulpr857/clean/crypto_decode_857x3.c | 10 +++++----- crypto_kem/sntrup653/avx2/crypto_core_mult3sntrup653.c | 2 +- crypto_kem/sntrup653/avx2/crypto_decode_653x1541.c | 4 ---- crypto_kem/sntrup653/avx2/crypto_decode_653x3.c | 2 +- crypto_kem/sntrup653/avx2/crypto_decode_653x4621.c | 4 ---- crypto_kem/sntrup653/clean/crypto_decode_653x3.c | 10 +++++----- crypto_kem/sntrup761/avx2/crypto_core_mult3sntrup761.c | 2 +- crypto_kem/sntrup761/avx2/crypto_decode_761x1531.c | 4 ---- crypto_kem/sntrup761/avx2/crypto_decode_761x3.c | 2 +- crypto_kem/sntrup761/avx2/crypto_decode_761x4591.c | 4 ---- crypto_kem/sntrup761/clean/crypto_decode_761x3.c | 10 +++++----- crypto_kem/sntrup857/avx2/crypto_core_mult3sntrup857.c | 2 +- crypto_kem/sntrup857/avx2/crypto_decode_857x1723.c | 4 ---- crypto_kem/sntrup857/avx2/crypto_decode_857x3.c | 2 +- crypto_kem/sntrup857/avx2/crypto_decode_857x5167.c | 4 ---- crypto_kem/sntrup857/clean/crypto_decode_857x3.c | 10 +++++----- 24 files changed, 39 insertions(+), 75 deletions(-) diff --git a/crypto_kem/ntrulpr653/avx2/crypto_decode_653x1541.c b/crypto_kem/ntrulpr653/avx2/crypto_decode_653x1541.c index e03c76a5..e54c65af 100644 --- a/crypto_kem/ntrulpr653/avx2/crypto_decode_653x1541.c +++ b/crypto_kem/ntrulpr653/avx2/crypto_decode_653x1541.c @@ -29,10 +29,6 @@ static inline __m256i signedshiftrightconst(__m256i x, int16 y) { return _mm256_srai_epi16(x, y); } -static inline __m256i addconst(__m256i x, int16 y) { - return add(x, _mm256_set1_epi16(y)); -} - static inline __m256i subconst(__m256i x, int16 y) { return sub(x, _mm256_set1_epi16(y)); } diff --git a/crypto_kem/ntrulpr653/avx2/crypto_decode_653x3.c b/crypto_kem/ntrulpr653/avx2/crypto_decode_653x3.c index de701e22..06724eb7 100644 --- a/crypto_kem/ntrulpr653/avx2/crypto_decode_653x3.c +++ b/crypto_kem/ntrulpr653/avx2/crypto_decode_653x3.c @@ -61,5 +61,5 @@ void PQCLEAN_NTRULPR653_AVX2_crypto_decode_653x3(void *v, const unsigned char *s nextf += 128; } - *f = ((uint8)(*s & 3)) - 1; + *f = (uint8) ((*s & 3) - 1); } diff --git a/crypto_kem/ntrulpr653/clean/crypto_decode_653x3.c b/crypto_kem/ntrulpr653/clean/crypto_decode_653x3.c index b703aac2..3f8204c3 100644 --- a/crypto_kem/ntrulpr653/clean/crypto_decode_653x3.c +++ b/crypto_kem/ntrulpr653/clean/crypto_decode_653x3.c @@ -11,14 +11,14 @@ void PQCLEAN_NTRULPR653_CLEAN_crypto_decode_653x3(void *v, const unsigned char * for (i = 0; i < p / 4; ++i) { x = *s++; - *f++ = ((uint8)(x & 3)) - 1; + *f++ = (uint8) ((x & 3) - 1); x >>= 2; - *f++ = ((uint8)(x & 3)) - 1; + *f++ = (uint8) ((x & 3) - 1); x >>= 2; - *f++ = ((uint8)(x & 3)) - 1; + *f++ = (uint8) ((x & 3) - 1); x >>= 2; - *f++ = ((uint8)(x & 3)) - 1; + *f++ = (uint8) ((x & 3) - 1); } x = *s++; - *f++ = ((uint8)(x & 3)) - 1; + *f++ = (uint8) ((x & 3) - 1); } diff --git a/crypto_kem/ntrulpr761/avx2/crypto_decode_761x1531.c b/crypto_kem/ntrulpr761/avx2/crypto_decode_761x1531.c index 730bd88c..82ce77dd 100644 --- a/crypto_kem/ntrulpr761/avx2/crypto_decode_761x1531.c +++ b/crypto_kem/ntrulpr761/avx2/crypto_decode_761x1531.c @@ -29,10 +29,6 @@ static inline __m256i signedshiftrightconst(__m256i x, int16 y) { return _mm256_srai_epi16(x, y); } -static inline __m256i addconst(__m256i x, int16 y) { - return add(x, _mm256_set1_epi16(y)); -} - static inline __m256i subconst(__m256i x, int16 y) { return sub(x, _mm256_set1_epi16(y)); } diff --git a/crypto_kem/ntrulpr761/avx2/crypto_decode_761x3.c b/crypto_kem/ntrulpr761/avx2/crypto_decode_761x3.c index 5c7cdcd9..06013fd2 100644 --- a/crypto_kem/ntrulpr761/avx2/crypto_decode_761x3.c +++ b/crypto_kem/ntrulpr761/avx2/crypto_decode_761x3.c @@ -61,5 +61,5 @@ void PQCLEAN_NTRULPR761_AVX2_crypto_decode_761x3(void *v, const unsigned char *s nextf += 128; } - *f = ((uint8)(*s & 3)) - 1; + *f = (uint8) ((*s & 3) - 1); } diff --git a/crypto_kem/ntrulpr761/clean/crypto_decode_761x3.c b/crypto_kem/ntrulpr761/clean/crypto_decode_761x3.c index ec73b604..d18ed794 100644 --- a/crypto_kem/ntrulpr761/clean/crypto_decode_761x3.c +++ b/crypto_kem/ntrulpr761/clean/crypto_decode_761x3.c @@ -11,14 +11,14 @@ void PQCLEAN_NTRULPR761_CLEAN_crypto_decode_761x3(void *v, const unsigned char * for (i = 0; i < p / 4; ++i) { x = *s++; - *f++ = ((uint8)(x & 3)) - 1; + *f++ = (uint8) ((x & 3) - 1); x >>= 2; - *f++ = ((uint8)(x & 3)) - 1; + *f++ = (uint8) ((x & 3) - 1); x >>= 2; - *f++ = ((uint8)(x & 3)) - 1; + *f++ = (uint8) ((x & 3) - 1); x >>= 2; - *f++ = ((uint8)(x & 3)) - 1; + *f++ = (uint8) ((x & 3) - 1); } x = *s++; - *f++ = ((uint8)(x & 3)) - 1; + *f++ = (uint8) ((x & 3) - 1); } diff --git a/crypto_kem/ntrulpr857/avx2/crypto_decode_857x1723.c b/crypto_kem/ntrulpr857/avx2/crypto_decode_857x1723.c index f76abc32..7f1f07b8 100644 --- a/crypto_kem/ntrulpr857/avx2/crypto_decode_857x1723.c +++ b/crypto_kem/ntrulpr857/avx2/crypto_decode_857x1723.c @@ -29,10 +29,6 @@ static inline __m256i signedshiftrightconst(__m256i x, int16 y) { return _mm256_srai_epi16(x, y); } -static inline __m256i addconst(__m256i x, int16 y) { - return add(x, _mm256_set1_epi16(y)); -} - static inline __m256i subconst(__m256i x, int16 y) { return sub(x, _mm256_set1_epi16(y)); } diff --git a/crypto_kem/ntrulpr857/avx2/crypto_decode_857x3.c b/crypto_kem/ntrulpr857/avx2/crypto_decode_857x3.c index a886f960..c6565cc3 100644 --- a/crypto_kem/ntrulpr857/avx2/crypto_decode_857x3.c +++ b/crypto_kem/ntrulpr857/avx2/crypto_decode_857x3.c @@ -61,5 +61,5 @@ void PQCLEAN_NTRULPR857_AVX2_crypto_decode_857x3(void *v, const unsigned char *s nextf += 128; } - *f = ((uint8)(*s & 3)) - 1; + *f = (uint8) ((*s & 3) - 1); } diff --git a/crypto_kem/ntrulpr857/clean/crypto_decode_857x3.c b/crypto_kem/ntrulpr857/clean/crypto_decode_857x3.c index 9b950df8..dead3ac3 100644 --- a/crypto_kem/ntrulpr857/clean/crypto_decode_857x3.c +++ b/crypto_kem/ntrulpr857/clean/crypto_decode_857x3.c @@ -11,14 +11,14 @@ void PQCLEAN_NTRULPR857_CLEAN_crypto_decode_857x3(void *v, const unsigned char * for (i = 0; i < p / 4; ++i) { x = *s++; - *f++ = ((uint8)(x & 3)) - 1; + *f++ = (uint8) ((x & 3) - 1); x >>= 2; - *f++ = ((uint8)(x & 3)) - 1; + *f++ = (uint8) ((x & 3) - 1); x >>= 2; - *f++ = ((uint8)(x & 3)) - 1; + *f++ = (uint8) ((x & 3) - 1); x >>= 2; - *f++ = ((uint8)(x & 3)) - 1; + *f++ = (uint8) ((x & 3) - 1); } x = *s++; - *f++ = ((uint8)(x & 3)) - 1; + *f++ = (uint8) ((x & 3) - 1); } diff --git a/crypto_kem/sntrup653/avx2/crypto_core_mult3sntrup653.c b/crypto_kem/sntrup653/avx2/crypto_core_mult3sntrup653.c index b1b50703..4160d770 100644 --- a/crypto_kem/sntrup653/avx2/crypto_core_mult3sntrup653.c +++ b/crypto_kem/sntrup653/avx2/crypto_core_mult3sntrup653.c @@ -241,7 +241,7 @@ int PQCLEAN_SNTRUP653_AVX2_crypto_core_mult3sntrup653(unsigned char *outbytes, c mult768(fg, f, g); - fg[0] -= fg[p - 1]; + fg[0] = (int16) (fg[0] - fg[p - 1]); for (i = 0; i < 768; i += 16) { int16x16 fgi = load_x16(&fg[i]); int16x16 fgip = load_x16(&fg[i + p]); diff --git a/crypto_kem/sntrup653/avx2/crypto_decode_653x1541.c b/crypto_kem/sntrup653/avx2/crypto_decode_653x1541.c index 493a936e..2d3973f0 100644 --- a/crypto_kem/sntrup653/avx2/crypto_decode_653x1541.c +++ b/crypto_kem/sntrup653/avx2/crypto_decode_653x1541.c @@ -29,10 +29,6 @@ static inline __m256i signedshiftrightconst(__m256i x, int16 y) { return _mm256_srai_epi16(x, y); } -static inline __m256i addconst(__m256i x, int16 y) { - return add(x, _mm256_set1_epi16(y)); -} - static inline __m256i subconst(__m256i x, int16 y) { return sub(x, _mm256_set1_epi16(y)); } diff --git a/crypto_kem/sntrup653/avx2/crypto_decode_653x3.c b/crypto_kem/sntrup653/avx2/crypto_decode_653x3.c index 3dc5c580..8e3ec8d9 100644 --- a/crypto_kem/sntrup653/avx2/crypto_decode_653x3.c +++ b/crypto_kem/sntrup653/avx2/crypto_decode_653x3.c @@ -61,5 +61,5 @@ void PQCLEAN_SNTRUP653_AVX2_crypto_decode_653x3(void *v, const unsigned char *s) nextf += 128; } - *f = ((uint8)(*s & 3)) - 1; + *f = (uint8) ((*s & 3) - 1); } diff --git a/crypto_kem/sntrup653/avx2/crypto_decode_653x4621.c b/crypto_kem/sntrup653/avx2/crypto_decode_653x4621.c index 91468ec6..e3d30bf5 100644 --- a/crypto_kem/sntrup653/avx2/crypto_decode_653x4621.c +++ b/crypto_kem/sntrup653/avx2/crypto_decode_653x4621.c @@ -29,10 +29,6 @@ static inline __m256i signedshiftrightconst(__m256i x, int16 y) { return _mm256_srai_epi16(x, y); } -static inline __m256i addconst(__m256i x, int16 y) { - return add(x, _mm256_set1_epi16(y)); -} - static inline __m256i subconst(__m256i x, int16 y) { return sub(x, _mm256_set1_epi16(y)); } diff --git a/crypto_kem/sntrup653/clean/crypto_decode_653x3.c b/crypto_kem/sntrup653/clean/crypto_decode_653x3.c index ccb11adb..a5e0641c 100644 --- a/crypto_kem/sntrup653/clean/crypto_decode_653x3.c +++ b/crypto_kem/sntrup653/clean/crypto_decode_653x3.c @@ -11,14 +11,14 @@ void PQCLEAN_SNTRUP653_CLEAN_crypto_decode_653x3(void *v, const unsigned char *s for (i = 0; i < p / 4; ++i) { x = *s++; - *f++ = ((uint8)(x & 3)) - 1; + *f++ = (uint8) ((x & 3) - 1); x >>= 2; - *f++ = ((uint8)(x & 3)) - 1; + *f++ = (uint8) ((x & 3) - 1); x >>= 2; - *f++ = ((uint8)(x & 3)) - 1; + *f++ = (uint8) ((x & 3) - 1); x >>= 2; - *f++ = ((uint8)(x & 3)) - 1; + *f++ = (uint8) ((x & 3) - 1); } x = *s++; - *f++ = ((uint8)(x & 3)) - 1; + *f++ = (uint8) ((x & 3) - 1); } diff --git a/crypto_kem/sntrup761/avx2/crypto_core_mult3sntrup761.c b/crypto_kem/sntrup761/avx2/crypto_core_mult3sntrup761.c index 4a6ddcdc..7e46dde5 100644 --- a/crypto_kem/sntrup761/avx2/crypto_core_mult3sntrup761.c +++ b/crypto_kem/sntrup761/avx2/crypto_core_mult3sntrup761.c @@ -241,7 +241,7 @@ int PQCLEAN_SNTRUP761_AVX2_crypto_core_mult3sntrup761(unsigned char *outbytes, c mult768(fg, f, g); - fg[0] -= fg[p - 1]; + fg[0] = (int16) (fg[0] - fg[p - 1]); for (i = 0; i < 768; i += 16) { int16x16 fgi = load_x16(&fg[i]); int16x16 fgip = load_x16(&fg[i + p]); diff --git a/crypto_kem/sntrup761/avx2/crypto_decode_761x1531.c b/crypto_kem/sntrup761/avx2/crypto_decode_761x1531.c index 7de1f43d..aa567462 100644 --- a/crypto_kem/sntrup761/avx2/crypto_decode_761x1531.c +++ b/crypto_kem/sntrup761/avx2/crypto_decode_761x1531.c @@ -29,10 +29,6 @@ static inline __m256i signedshiftrightconst(__m256i x, int16 y) { return _mm256_srai_epi16(x, y); } -static inline __m256i addconst(__m256i x, int16 y) { - return add(x, _mm256_set1_epi16(y)); -} - static inline __m256i subconst(__m256i x, int16 y) { return sub(x, _mm256_set1_epi16(y)); } diff --git a/crypto_kem/sntrup761/avx2/crypto_decode_761x3.c b/crypto_kem/sntrup761/avx2/crypto_decode_761x3.c index a377eca4..73b0f092 100644 --- a/crypto_kem/sntrup761/avx2/crypto_decode_761x3.c +++ b/crypto_kem/sntrup761/avx2/crypto_decode_761x3.c @@ -61,5 +61,5 @@ void PQCLEAN_SNTRUP761_AVX2_crypto_decode_761x3(void *v, const unsigned char *s) nextf += 128; } - *f = ((uint8)(*s & 3)) - 1; + *f = (uint8) ((*s & 3) - 1); } diff --git a/crypto_kem/sntrup761/avx2/crypto_decode_761x4591.c b/crypto_kem/sntrup761/avx2/crypto_decode_761x4591.c index c8e3bfbc..ea31ac79 100644 --- a/crypto_kem/sntrup761/avx2/crypto_decode_761x4591.c +++ b/crypto_kem/sntrup761/avx2/crypto_decode_761x4591.c @@ -29,10 +29,6 @@ static inline __m256i signedshiftrightconst(__m256i x, int16 y) { return _mm256_srai_epi16(x, y); } -static inline __m256i addconst(__m256i x, int16 y) { - return add(x, _mm256_set1_epi16(y)); -} - static inline __m256i subconst(__m256i x, int16 y) { return sub(x, _mm256_set1_epi16(y)); } diff --git a/crypto_kem/sntrup761/clean/crypto_decode_761x3.c b/crypto_kem/sntrup761/clean/crypto_decode_761x3.c index 394b0ccb..d5d69508 100644 --- a/crypto_kem/sntrup761/clean/crypto_decode_761x3.c +++ b/crypto_kem/sntrup761/clean/crypto_decode_761x3.c @@ -11,14 +11,14 @@ void PQCLEAN_SNTRUP761_CLEAN_crypto_decode_761x3(void *v, const unsigned char *s for (i = 0; i < p / 4; ++i) { x = *s++; - *f++ = ((uint8)(x & 3)) - 1; + *f++ = (uint8) ((x & 3) - 1); x >>= 2; - *f++ = ((uint8)(x & 3)) - 1; + *f++ = (uint8) ((x & 3) - 1); x >>= 2; - *f++ = ((uint8)(x & 3)) - 1; + *f++ = (uint8) ((x & 3) - 1); x >>= 2; - *f++ = ((uint8)(x & 3)) - 1; + *f++ = (uint8) ((x & 3) - 1); } x = *s++; - *f++ = ((uint8)(x & 3)) - 1; + *f++ = (uint8) ((x & 3) - 1); } diff --git a/crypto_kem/sntrup857/avx2/crypto_core_mult3sntrup857.c b/crypto_kem/sntrup857/avx2/crypto_core_mult3sntrup857.c index c39cc70d..ed13df3b 100644 --- a/crypto_kem/sntrup857/avx2/crypto_core_mult3sntrup857.c +++ b/crypto_kem/sntrup857/avx2/crypto_core_mult3sntrup857.c @@ -278,7 +278,7 @@ int PQCLEAN_SNTRUP857_AVX2_crypto_core_mult3sntrup857(unsigned char *outbytes, c mult1024(fg, f, g); - fg[0] -= fg[p - 1]; + fg[0] = (int16) (fg[0] - fg[p - 1]); for (i = 0; i < 1024; i += 16) { int16x16 fgi = load_x16(&fg[i]); int16x16 fgip = load_x16(&fg[i + p]); diff --git a/crypto_kem/sntrup857/avx2/crypto_decode_857x1723.c b/crypto_kem/sntrup857/avx2/crypto_decode_857x1723.c index 2691eb2b..a0febc10 100644 --- a/crypto_kem/sntrup857/avx2/crypto_decode_857x1723.c +++ b/crypto_kem/sntrup857/avx2/crypto_decode_857x1723.c @@ -29,10 +29,6 @@ static inline __m256i signedshiftrightconst(__m256i x, int16 y) { return _mm256_srai_epi16(x, y); } -static inline __m256i addconst(__m256i x, int16 y) { - return add(x, _mm256_set1_epi16(y)); -} - static inline __m256i subconst(__m256i x, int16 y) { return sub(x, _mm256_set1_epi16(y)); } diff --git a/crypto_kem/sntrup857/avx2/crypto_decode_857x3.c b/crypto_kem/sntrup857/avx2/crypto_decode_857x3.c index 5a50a4d8..681f90ad 100644 --- a/crypto_kem/sntrup857/avx2/crypto_decode_857x3.c +++ b/crypto_kem/sntrup857/avx2/crypto_decode_857x3.c @@ -61,5 +61,5 @@ void PQCLEAN_SNTRUP857_AVX2_crypto_decode_857x3(void *v, const unsigned char *s) nextf += 128; } - *f = ((uint8)(*s & 3)) - 1; + *f = (uint8) ((*s & 3) - 1); } diff --git a/crypto_kem/sntrup857/avx2/crypto_decode_857x5167.c b/crypto_kem/sntrup857/avx2/crypto_decode_857x5167.c index 8280c00e..15699a8b 100644 --- a/crypto_kem/sntrup857/avx2/crypto_decode_857x5167.c +++ b/crypto_kem/sntrup857/avx2/crypto_decode_857x5167.c @@ -29,10 +29,6 @@ static inline __m256i signedshiftrightconst(__m256i x, int16 y) { return _mm256_srai_epi16(x, y); } -static inline __m256i addconst(__m256i x, int16 y) { - return add(x, _mm256_set1_epi16(y)); -} - static inline __m256i subconst(__m256i x, int16 y) { return sub(x, _mm256_set1_epi16(y)); } diff --git a/crypto_kem/sntrup857/clean/crypto_decode_857x3.c b/crypto_kem/sntrup857/clean/crypto_decode_857x3.c index b2f433e6..4fd43cd5 100644 --- a/crypto_kem/sntrup857/clean/crypto_decode_857x3.c +++ b/crypto_kem/sntrup857/clean/crypto_decode_857x3.c @@ -11,14 +11,14 @@ void PQCLEAN_SNTRUP857_CLEAN_crypto_decode_857x3(void *v, const unsigned char *s for (i = 0; i < p / 4; ++i) { x = *s++; - *f++ = ((uint8)(x & 3)) - 1; + *f++ = (uint8) ((x & 3) - 1); x >>= 2; - *f++ = ((uint8)(x & 3)) - 1; + *f++ = (uint8) ((x & 3) - 1); x >>= 2; - *f++ = ((uint8)(x & 3)) - 1; + *f++ = (uint8) ((x & 3) - 1); x >>= 2; - *f++ = ((uint8)(x & 3)) - 1; + *f++ = (uint8) ((x & 3) - 1); } x = *s++; - *f++ = ((uint8)(x & 3)) - 1; + *f++ = (uint8) ((x & 3) - 1); }