summaryrefslogtreecommitdiff
path: root/libyasm
diff options
context:
space:
mode:
authorPeter Johnson <peter@tortall.net>2007-02-24 20:19:27 +0000
committerPeter Johnson <peter@tortall.net>2007-02-24 20:19:27 +0000
commit2f2180767d47ece430fee1343ee357ca97d24770 (patch)
treeef77eebb6a0ca80484e61b687ce69d603dddd190 /libyasm
parentb0765a936c2cc5f0eb517c77660150aadb524e5a (diff)
downloadyasm-2f2180767d47ece430fee1343ee357ca97d24770.tar.gz
Massive warnings cleanup and cleanup of size_t vs uintptr_t vs unsigned long.
svn path=/trunk/yasm/; revision=1792
Diffstat (limited to 'libyasm')
-rw-r--r--libyasm/bitvect.c10
-rw-r--r--libyasm/coretype.h6
-rw-r--r--libyasm/expr.c4
-rw-r--r--libyasm/floatnum.c4
-rw-r--r--libyasm/intnum.c8
-rw-r--r--libyasm/md5.c2
-rw-r--r--libyasm/md5.h2
-rw-r--r--libyasm/mergesort.c3
-rw-r--r--libyasm/phash.c14
-rw-r--r--libyasm/phash.h4
10 files changed, 30 insertions, 27 deletions
diff --git a/libyasm/bitvect.c b/libyasm/bitvect.c
index abebc8f8..c39f9b65 100644
--- a/libyasm/bitvect.c
+++ b/libyasm/bitvect.c
@@ -1497,7 +1497,7 @@ ErrCode BitVector_from_Hex(wordptr addr, charptr string)
N_word size = size_(addr);
N_word mask = mask_(addr);
boolean ok = TRUE;
- N_word length;
+ size_t length;
N_word value;
N_word count;
int digit;
@@ -1534,7 +1534,7 @@ ErrCode BitVector_from_Oct(wordptr addr, charptr string)
N_word size = size_(addr);
N_word mask = mask_(addr);
boolean ok = TRUE;
- N_word length;
+ size_t length;
N_word value;
N_word value_fill = 0;
N_word count;
@@ -1609,7 +1609,7 @@ ErrCode BitVector_from_Bin(wordptr addr, charptr string)
N_word size = size_(addr);
N_word mask = mask_(addr);
boolean ok = TRUE;
- N_word length;
+ size_t length;
N_word value;
N_word count;
int digit;
@@ -1819,7 +1819,7 @@ ErrCode BitVector_from_Dec_static(BitVector_from_Dec_static_data *data,
N_word accu;
N_word powr;
N_word count;
- N_word length;
+ size_t length;
int digit;
if (bits > 0)
@@ -1930,7 +1930,7 @@ ErrCode BitVector_from_Dec(wordptr addr, charptr string)
N_word accu;
N_word powr;
N_word count;
- N_word length;
+ size_t length;
int digit;
if (bits > 0)
diff --git a/libyasm/coretype.h b/libyasm/coretype.h
index 1e22709a..a6b92b04 100644
--- a/libyasm/coretype.h
+++ b/libyasm/coretype.h
@@ -260,7 +260,7 @@ typedef enum yasm_sym_vis {
* \return Nonzero if an error occurred, 0 otherwise.
*/
typedef int (*yasm_output_value_func)
- (yasm_value *value, /*@out@*/ unsigned char *buf, size_t destsize,
+ (yasm_value *value, /*@out@*/ unsigned char *buf, unsigned int destsize,
unsigned long offset, yasm_bytecode *bc, int warn, /*@null@*/ void *d);
/** Convert a symbol reference to its byte representation. Usually implemented
@@ -281,8 +281,8 @@ typedef int (*yasm_output_value_func)
* \return Nonzero if an error occurred, 0 otherwise.
*/
typedef int (*yasm_output_reloc_func)
- (yasm_symrec *sym, yasm_bytecode *bc, unsigned char *buf, size_t destsize,
- size_t valsize, int warn, void *d);
+ (yasm_symrec *sym, yasm_bytecode *bc, unsigned char *buf,
+ unsigned int destsize, unsigned int valsize, int warn, void *d);
/** Sort an array using merge sort algorithm.
* \internal
diff --git a/libyasm/expr.c b/libyasm/expr.c
index 461dd1bc..4495b28f 100644
--- a/libyasm/expr.c
+++ b/libyasm/expr.c
@@ -75,7 +75,7 @@ yasm_expr_create(yasm_expr_op op, yasm_expr__item *left,
ptr->terms[1].type = YASM_EXPR_NONE;
if (left) {
ptr->terms[0] = *left; /* structure copy */
- z = left-itempool;
+ z = (unsigned long)(left-itempool);
if (z>=31)
yasm_internal_error(N_("could not find expritem in pool"));
itempool_used &= ~(1<<z);
@@ -98,7 +98,7 @@ yasm_expr_create(yasm_expr_op op, yasm_expr__item *left,
if (right) {
ptr->terms[1] = *right; /* structure copy */
- z = right-itempool;
+ z = (unsigned long)(right-itempool);
if (z>=31)
yasm_internal_error(N_("could not find expritem in pool"));
itempool_used &= ~(1<<z);
diff --git a/libyasm/floatnum.c b/libyasm/floatnum.c
index 3ddd93ea..09dddc27 100644
--- a/libyasm/floatnum.c
+++ b/libyasm/floatnum.c
@@ -226,7 +226,7 @@ floatnum_normalize(yasm_floatnum *flt)
if (norm_amt > (long)flt->exponent)
norm_amt = (long)flt->exponent;
BitVector_Move_Left(flt->mantissa, (N_int)norm_amt);
- flt->exponent -= norm_amt;
+ flt->exponent -= (unsigned short)norm_amt;
}
/* acc *= op */
@@ -291,7 +291,7 @@ floatnum_mul(yasm_floatnum *acc, const yasm_floatnum *op)
if (norm_amt > (long)acc->exponent)
norm_amt = (long)acc->exponent;
BitVector_Move_Left(product, (N_int)norm_amt);
- acc->exponent -= norm_amt;
+ acc->exponent -= (unsigned short)norm_amt;
/* Store the highest bits of the result */
BitVector_Interval_Copy(acc->mantissa, product, 0, MANT_BITS, MANT_BITS);
diff --git a/libyasm/intnum.c b/libyasm/intnum.c
index 3f06c3b5..3b3ad374 100644
--- a/libyasm/intnum.c
+++ b/libyasm/intnum.c
@@ -288,7 +288,7 @@ yasm_intnum_create_leb128(const unsigned char *ptr, int sign,
ptr++;
}
- *size = (ptr-ptr_orig)+1;
+ *size = (unsigned long)(ptr-ptr_orig)+1;
if(i > BITVECT_NATIVE_SIZE)
yasm_error_set(YASM_ERROR_OVERFLOW,
@@ -730,7 +730,7 @@ yasm_intnum_get_sized(const yasm_intnum *intn, unsigned char *ptr,
/* TODO */
yasm_internal_error(N_("big endian not implemented"));
} else
- BitVector_Block_Store(op1, ptr, destsize);
+ BitVector_Block_Store(op1, ptr, (N_int)destsize);
/* If not already a bitvect, convert value to be written to a bitvect */
if (intn->type == INTNUM_BV)
@@ -744,7 +744,7 @@ yasm_intnum_get_sized(const yasm_intnum *intn, unsigned char *ptr,
/* Check low bits if right shifting and warnings enabled */
if (warn && rshift > 0) {
BitVector_Copy(conv_bv, op2);
- BitVector_Move_Left(conv_bv, BITVECT_NATIVE_SIZE-rshift);
+ BitVector_Move_Left(conv_bv, (N_int)(BITVECT_NATIVE_SIZE-rshift));
if (!BitVector_is_empty(conv_bv))
yasm_warn_set(YASM_WARN_GENERAL,
N_("misaligned value, truncating to boundary"));
@@ -759,7 +759,7 @@ yasm_intnum_get_sized(const yasm_intnum *intn, unsigned char *ptr,
}
/* Write the new value into the destination bitvect */
- BitVector_Interval_Copy(op1, op2, (unsigned int)shift, 0, valsize);
+ BitVector_Interval_Copy(op1, op2, (unsigned int)shift, 0, (N_int)valsize);
/* Write out the new data */
buf = BitVector_Block_Read(op1, &len);
diff --git a/libyasm/md5.c b/libyasm/md5.c
index d53ef378..af045fbe 100644
--- a/libyasm/md5.c
+++ b/libyasm/md5.c
@@ -77,7 +77,7 @@ yasm_md5_init(yasm_md5_context *ctx)
*/
void
yasm_md5_update(yasm_md5_context *ctx, unsigned char const *buf,
- unsigned len)
+ unsigned long len)
{
unsigned long t;
diff --git a/libyasm/md5.h b/libyasm/md5.h
index 52559a0d..91be1c55 100644
--- a/libyasm/md5.h
+++ b/libyasm/md5.h
@@ -21,7 +21,7 @@ typedef struct yasm_md5_context {
void yasm_md5_init(yasm_md5_context *context);
void yasm_md5_update(yasm_md5_context *context, unsigned char const *buf,
- unsigned len);
+ unsigned long len);
void yasm_md5_final(unsigned char digest[16], yasm_md5_context *context);
void yasm_md5_transform(unsigned long buf[4], const unsigned char in[64]);
diff --git a/libyasm/mergesort.c b/libyasm/mergesort.c
index e460a178..87e451d0 100644
--- a/libyasm/mergesort.c
+++ b/libyasm/mergesort.c
@@ -278,7 +278,8 @@ setup(unsigned char *list1, unsigned char *list2, size_t n, size_t size,
{
size_t i;
unsigned int tmp;
- int length, size2, sense;
+ int length, sense;
+ size_t size2;
unsigned char *f1, *f2, *s, *l2, *last, *p2;
size2 = size*2;
diff --git a/libyasm/phash.c b/libyasm/phash.c
index b828bb65..01941c28 100644
--- a/libyasm/phash.c
+++ b/libyasm/phash.c
@@ -96,10 +96,11 @@ acceptable. Do NOT use for cryptographic purposes.
unsigned long
phash_lookup(
register const char *sk, /* the key */
- register unsigned long length, /* the length of the key */
+ register size_t length, /* the length of the key */
register unsigned long level) /* the previous hash, or an arbitrary value */
{
- register unsigned long a,b,c,len;
+ register unsigned long a,b,c;
+ register size_t len;
register const unsigned char *k = (const unsigned char *)sk;
/* Set up the internal state */
@@ -121,7 +122,7 @@ phash_lookup(
}
/*------------------------------------- handle the last 11 bytes */
- c += length;
+ c += (ub4)length;
switch(len) /* all the case statements fall through */
{
case 11: c+=((ub4)k[10]<<24);
@@ -192,10 +193,11 @@ is trying to cause collisions. Do NOT use for cryptography.
void
phash_checksum(
register const char *sk,
- register unsigned long len,
+ register size_t len,
register unsigned long *state)
{
- register unsigned long a,b,c,d,e,f,g,h,length;
+ register unsigned long a,b,c,d,e,f,g,h;
+ register size_t length;
register const unsigned char *k = (const unsigned char *)sk;
/* Use the length and level; add in the golden ratio. */
@@ -222,7 +224,7 @@ phash_checksum(
}
/*------------------------------------- handle the last 31 bytes */
- h += length;
+ h += (ub4)length;
switch(len)
{
case 31: h+=(k[30]<<24);
diff --git a/libyasm/phash.h b/libyasm/phash.h
index 5fc44e39..bf4cb47c 100644
--- a/libyasm/phash.h
+++ b/libyasm/phash.h
@@ -10,6 +10,6 @@ Source is http://burtleburtle.net/bob/c/lookupa.h
------------------------------------------------------------------------------
*/
-unsigned long phash_lookup(const char *k, unsigned long length,
+unsigned long phash_lookup(const char *k, size_t length,
unsigned long level);
-void phash_checksum(const char *k, unsigned long length, unsigned long *state);
+void phash_checksum(const char *k, size_t length, unsigned long *state);