Browse Source

Merge pull request #379 from libtom/pr/clang-tidy-misc-misplaced-widening-cast

clang-tidy: misc-misplaced-widening-cast
(cherry picked from commit 248352c36f0352f8d7cb202499e825900af76151)

With back-ported patch from src/misc/copy_or_zeromem.c back to
src/encauth/ccm/ccm_memory.c
karel-m 7 years ago
parent
commit
d16e5b0b05

+ 1 - 1
src/encauth/ccm/ccm_memory.c

@@ -52,7 +52,7 @@ int ccm_memory(int cipher,
    int            err;
    int            err;
    unsigned long  len, L, x, y, z, CTRlen;
    unsigned long  len, L, x, y, z, CTRlen;
 #ifdef LTC_FAST
 #ifdef LTC_FAST
-   LTC_FAST_TYPE fastMask = ~0; /* initialize fastMask at all zeroes */
+   LTC_FAST_TYPE fastMask = ~(LTC_FAST_TYPE)0; /* initialize fastMask at all zeroes */
 #endif
 #endif
    unsigned char mask = 0xff; /* initialize mask at all zeroes */
    unsigned char mask = 0xff; /* initialize mask at all zeroes */
 
 

+ 1 - 1
src/pk/dsa/dsa_export.c

@@ -69,7 +69,7 @@ int dsa_export(unsigned char *out, unsigned long *outlen, int type, dsa_key *key
       }
       }
    } else {
    } else {
       if (std) {
       if (std) {
-          unsigned long tmplen = (mp_count_bits(key->y) / 8) + 8;
+          unsigned long tmplen = (unsigned long)(mp_count_bits(key->y) / 8) + 8;
           unsigned char* tmp = XMALLOC(tmplen);
           unsigned char* tmp = XMALLOC(tmplen);
           ltc_asn1_list int_list[3];
           ltc_asn1_list int_list[3];
 
 

+ 2 - 2
src/pk/dsa/dsa_generate_pqg.c

@@ -72,8 +72,8 @@ static int _dsa_make_params(prng_state *prng, int wprng, int group_size, int mod
   */
   */
 
 
   seedbytes = group_size;
   seedbytes = group_size;
-  L = modulus_size * 8;
-  N = group_size * 8;
+  L = (unsigned long)modulus_size * 8;
+  N = (unsigned long)group_size * 8;
 
 
   /* XXX-TODO no Lucas test */
   /* XXX-TODO no Lucas test */
 #ifdef LTC_MPI_HAS_LUCAS_TEST
 #ifdef LTC_MPI_HAS_LUCAS_TEST

+ 1 - 1
src/pk/rsa/rsa_export.c

@@ -58,7 +58,7 @@ int rsa_export(unsigned char *out, unsigned long *outlen, int type, rsa_key *key
       unsigned char* tmp = NULL;
       unsigned char* tmp = NULL;
 
 
       if (type & PK_STD) {
       if (type & PK_STD) {
-          tmplen = (mp_count_bits(key->N)/8)*2+8;
+          tmplen = (unsigned long)(mp_count_bits(key->N) / 8) * 2 + 8;
           tmp = XMALLOC(tmplen);
           tmp = XMALLOC(tmplen);
           ptmplen = &tmplen;
           ptmplen = &tmplen;
           if (tmp == NULL) {
           if (tmp == NULL) {