Strict C99: don't use a signed* when an unsigned* is expected

It works in practice on almost every platform, given that we're only
using the wrong type in cases where the value is guaranteed to stay
within the value bits of a signed int. But even in this case it may or
may not be strictly conforming. Anyway `gcc -std=c99 -pedantic`
rejects it.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
Gilles Peskine 2020-04-14 19:34:19 +02:00
parent 1a75d0c155
commit a5fc939bdd
4 changed files with 7 additions and 4 deletions

View File

@ -85,7 +85,8 @@ int main( void )
int main( int argc, char *argv[] ) int main( int argc, char *argv[] )
{ {
int ret = 1, i, n; int ret = 1, i;
unsigned n;
int exit_code = MBEDTLS_EXIT_FAILURE; int exit_code = MBEDTLS_EXIT_FAILURE;
int mode; int mode;
size_t keylen, ilen, olen; size_t keylen, ilen, olen;

View File

@ -64,7 +64,8 @@ int main( void )
int main( int argc, char *argv[] ) int main( int argc, char *argv[] )
{ {
FILE *f; FILE *f;
int ret = 1, c; int ret = 1;
unsigned c;
int exit_code = MBEDTLS_EXIT_FAILURE; int exit_code = MBEDTLS_EXIT_FAILURE;
size_t i, olen = 0; size_t i, olen = 0;
mbedtls_pk_context pk; mbedtls_pk_context pk;

View File

@ -65,7 +65,7 @@ int main( int argc, char *argv[] )
FILE *f; FILE *f;
int ret = 1; int ret = 1;
int exit_code = MBEDTLS_EXIT_FAILURE; int exit_code = MBEDTLS_EXIT_FAILURE;
int c; unsigned c;
size_t i; size_t i;
mbedtls_rsa_context rsa; mbedtls_rsa_context rsa;
mbedtls_mpi N, P, Q, D, E, DP, DQ, QP; mbedtls_mpi N, P, Q, D, E, DP, DQ, QP;

View File

@ -59,7 +59,8 @@ int main( void )
int main( int argc, char *argv[] ) int main( int argc, char *argv[] )
{ {
FILE *f; FILE *f;
int ret = 1, c; int ret = 1;
unsigned c;
int exit_code = MBEDTLS_EXIT_FAILURE; int exit_code = MBEDTLS_EXIT_FAILURE;
size_t i; size_t i;
mbedtls_rsa_context rsa; mbedtls_rsa_context rsa;