Bug 1639033 - Use unsigned int for various count variables in mplogic.c to eliminate signed-unsigned comparison warnings. r=kjacobs
authorJeff Walden <jwalden@mit.edu>
Thu, 21 May 2020 20:08:26 +0000
changeset 15628 ce5b8b7e010cca549faaf067f7315ae03dfe258b
parent 15627 563a7cd7484bde21b387dda2b0b7e4e5a049f7cf
child 15629 df5c8f6430a027353c46103a26e057cfa1a760db
push id3751
push userkjacobs@mozilla.com
push dateFri, 22 May 2020 20:56:57 +0000
reviewerskjacobs
bugs1639033
Bug 1639033 - Use unsigned int for various count variables in mplogic.c to eliminate signed-unsigned comparison warnings. r=kjacobs Depends on D75844 Differential Revision: https://phabricator.services.mozilla.com/D75845
lib/freebl/mpi/mplogic.c
lib/freebl/mpi/mplogic.h
--- a/lib/freebl/mpi/mplogic.c
+++ b/lib/freebl/mpi/mplogic.c
@@ -217,20 +217,19 @@ mpl_lsh(const mp_int *a, mp_int *b, mp_d
   not considered an error.
 
   mpl_num_clear() does basically the same thing for clear bits.
  */
 
 /* {{{ mpl_num_set(a, num) */
 
 mp_err
-mpl_num_set(mp_int *a, int *num)
+mpl_num_set(mp_int *a, unsigned int *num)
 {
-    unsigned int ix;
-    int db, nset = 0;
+    unsigned int ix, db, nset = 0;
     mp_digit cur;
     unsigned char reg;
 
     ARGCHK(a != NULL, MP_BADARG);
 
     for (ix = 0; ix < USED(a); ix++) {
         cur = DIGIT(a, ix);
 
@@ -248,20 +247,19 @@ mpl_num_set(mp_int *a, int *num)
 
 } /* end mpl_num_set() */
 
 /* }}} */
 
 /* {{{ mpl_num_clear(a, num) */
 
 mp_err
-mpl_num_clear(mp_int *a, int *num)
+mpl_num_clear(mp_int *a, unsigned int *num)
 {
-    unsigned int ix;
-    int db, nset = 0;
+    unsigned int ix, db, nset = 0;
     mp_digit cur;
     unsigned char reg;
 
     ARGCHK(a != NULL, MP_BADARG);
 
     for (ix = 0; ix < USED(a); ix++) {
         cur = DIGIT(a, ix);
 
--- a/lib/freebl/mpi/mplogic.h
+++ b/lib/freebl/mpi/mplogic.h
@@ -34,19 +34,19 @@ mp_err mpl_xor(mp_int *a, mp_int *b, mp_
 
 /* Shift functions                   */
 
 mp_err mpl_rsh(const mp_int *a, mp_int *b, mp_digit d); /* right shift    */
 mp_err mpl_lsh(const mp_int *a, mp_int *b, mp_digit d); /* left shift     */
 
 /* Bit count and parity              */
 
-mp_err mpl_num_set(mp_int *a, int *num);   /* count set bits    */
-mp_err mpl_num_clear(mp_int *a, int *num); /* count clear bits  */
-mp_err mpl_parity(mp_int *a);              /* determine parity  */
+mp_err mpl_num_set(mp_int *a, unsigned int *num);   /* count set bits    */
+mp_err mpl_num_clear(mp_int *a, unsigned int *num); /* count clear bits  */
+mp_err mpl_parity(mp_int *a);                       /* determine parity  */
 
 /* Get & Set the value of a bit */
 
 mp_err mpl_set_bit(mp_int *a, mp_size bitNum, mp_size value);
 mp_err mpl_get_bit(const mp_int *a, mp_size bitNum);
 mp_err mpl_get_bits(const mp_int *a, mp_size lsbNum, mp_size numBits);
 mp_size mpl_significant_bits(const mp_int *a);