Browse Source

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

clang-tidy: misc-misplaced-widening-cast
karel-m 7 years ago
parent
commit
248352c36f

+ 1 - 1
src/misc/copy_or_zeromem.c

@@ -25,7 +25,7 @@ void copy_or_zeromem(const unsigned char* src, unsigned char* dest, unsigned lon
    unsigned long y;
    unsigned long y;
 #ifdef LTC_FAST
 #ifdef LTC_FAST
    unsigned long z;
    unsigned long z;
-   LTC_FAST_TYPE fastMask = ~0; /* initialize fastMask at all ones */
+   LTC_FAST_TYPE fastMask = ~(LTC_FAST_TYPE)0; /* initialize fastMask at all ones */
 #endif
 #endif
    unsigned char mask = 0xff; /* initialize mask at all ones */
    unsigned char mask = 0xff; /* initialize mask at all ones */
 
 

+ 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) {