Commit a921df6d authored by J.H.M. Dassen's avatar J.H.M. Dassen Committed by Niels Möller
Browse files

Signedness fixes (int->size_t) by jdassen@wi.leidenuniv.nl.

Rev: src/bignum.c:1.9
Rev: src/charset.c:1.4
parent 484697cc
......@@ -26,6 +26,8 @@
#include "bignum.h"
#include "werror.h"
#include <stdlib.h>
static void limbs_to_octets(mpz_t n, UINT32 length,
UINT8 pad, UINT8 *data)
{
......@@ -38,7 +40,7 @@ static void limbs_to_octets(mpz_t n, UINT32 length,
(length > 0) && (left > 0);
left--)
{
int i;
size_t i;
mp_limb_t word = *l++;
for(i = 0; i<sizeof(mp_limb_t); i++)
{
......@@ -60,7 +62,7 @@ static void limbs_to_octets(mpz_t n, UINT32 length,
void bignum_parse_s(mpz_t n, UINT32 length, UINT8 *data)
{
int negative = length && (*data & 0x80);
int i;
size_t i;
mpz_t digit;
mpz_init(digit);
......@@ -121,7 +123,7 @@ UINT32 bignum_format_s(mpz_t n, UINT8 *data)
return 0;
case 1:
{
int length = mpz_sizeinbase(n, 2)/8 + 1;
size_t length = mpz_sizeinbase(n, 2)/8 + 1;
limbs_to_octets(n, length, 0, data);
return length;
......@@ -129,7 +131,7 @@ UINT32 bignum_format_s(mpz_t n, UINT8 *data)
case -1:
{
mpz_t complement;
int length;
size_t length;
int i;
mpz_init(complement);
......@@ -154,7 +156,7 @@ UINT32 bignum_format_s(mpz_t n, UINT8 *data)
/* Formatting of unsigned numbers */
void bignum_parse_u(mpz_t n, UINT32 length, UINT8 *data)
{
int i;
size_t i;
mpz_t digit;
mpz_init(digit);
......@@ -189,7 +191,7 @@ UINT32 bignum_format_u(mpz_t n, UINT8 *data)
return 0;
case 1:
{
int length = (mpz_sizeinbase(n, 2) + 7) / 8;
size_t length = (mpz_sizeinbase(n, 2) + 7) / 8;
limbs_to_octets(n, length, 0, data);
return length;
......@@ -202,7 +204,7 @@ UINT32 bignum_format_u(mpz_t n, UINT8 *data)
void bignum_random(mpz_t x, struct randomness *random, mpz_t n)
{
/* Add a few bits extra */
int length = (mpz_sizeinbase(n, 2) + 17) / 8;
size_t length = (mpz_sizeinbase(n, 2) + 17) / 8;
UINT8 *data = alloca(length);
RANDOM(random, length, data);
......
......@@ -57,9 +57,9 @@ int ucs4_to_local(UINT32 c)
switch (local_charset)
{
case CHARSET_USASCII:
return (c < 0x80) ? c : -1;
return (c < 0x80) ? (int) c : -1;
case CHARSET_LATIN1:
return (c < 0x100) ? c : -1;
return (c < 0x100) ? (int) c : -1;
default:
fatal("Internal error");
};
......@@ -79,7 +79,7 @@ struct lsh_string *local_to_utf8(struct lsh_string *s, int free)
UINT32 total = 0;
{
int i;
UINT32 i;
/* First convert to ucs-4, and compute the length of the corresponding
* utf-8 string. */
......@@ -88,22 +88,22 @@ struct lsh_string *local_to_utf8(struct lsh_string *s, int free)
UINT32 c = local_to_ucs4(s->data[i]);
unsigned char l = 1;
if (c >= (1L<<7))
if (c >= (1UL<<7))
{
l++;
if (c >= (1L<<11))
if (c >= (1UL<<11))
{
l++;
if (c >= (1L<<16))
if (c >= (1UL<<16))
{
l++;
if (c >= (1L<<21))
if (c >= (1UL<<21))
{
l++;
if (c >= (1L<<25))
if (c >= (1UL<<25))
{
l++;
if (c >= (1L<<31))
if (c >= (1UL<<31))
fatal("Internal error!\n");
}}}}}
chars[i] = c;
......@@ -113,7 +113,7 @@ struct lsh_string *local_to_utf8(struct lsh_string *s, int free)
}
{
struct lsh_string *res = lsh_string_alloc(total);
int i, j;
UINT32 i, j;
for(i = j = 0; i<s->length; i++)
{
......@@ -148,7 +148,7 @@ struct lsh_string *local_to_utf8(struct lsh_string *s, int free)
struct lsh_string *utf8_to_local(struct lsh_string *s, int free)
{
int i;
UINT32 i;
struct lsh_string *res;
struct simple_buffer buffer;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment