From: Kovarththanan Rajaratnam Date: Mon, 22 Feb 2010 21:58:41 +0000 (+0100) Subject: use size_t when we refer to memory sizes X-Git-Tag: v3.0pre0~55^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8f2365f24df1e937f6e21446af2953ea9cab5a10;p=thirdparty%2Fccache.git use size_t when we refer to memory sizes --- diff --git a/ccache.h b/ccache.h index 9540c8c83..1a267ac32 100644 --- a/ccache.h +++ b/ccache.h @@ -56,7 +56,7 @@ int hash_fd(struct mdfour *md, int fd); int hash_file(struct mdfour *md, const char *fname); char *hash_result(struct mdfour *md); void hash_result_as_bytes(struct mdfour *md, unsigned char *out); -void hash_buffer(struct mdfour *md, const char *s, int len); +void hash_buffer(struct mdfour *md, const char *s, size_t len); void cc_log(const char *format, ...) ATTR_FORMAT(printf, 1, 2); void fatal(const char *format, ...) ATTR_FORMAT(printf, 1, 2); diff --git a/hash.c b/hash.c index bc300cef1..e2159d7c5 100644 --- a/hash.c +++ b/hash.c @@ -25,7 +25,7 @@ #include #include -void hash_buffer(struct mdfour *md, const char *s, int len) +void hash_buffer(struct mdfour *md, const char *s, size_t len) { mdfour_update(md, (unsigned char *)s, len); } @@ -51,7 +51,7 @@ void hash_int(struct mdfour *md, int x) int hash_fd(struct mdfour *md, int fd) { char buf[1024]; - int n; + size_t n; while ((n = read(fd, buf, sizeof(buf))) > 0) { hash_buffer(md, buf, n); diff --git a/mdfour.c b/mdfour.c index e81501247..f156153c1 100644 --- a/mdfour.c +++ b/mdfour.c @@ -110,7 +110,7 @@ void mdfour_begin(struct mdfour *md) } -static void mdfour_tail(const unsigned char *in, int n) +static void mdfour_tail(const unsigned char *in, size_t n) { unsigned char buf[128]; uint32_t M[16]; @@ -137,7 +137,7 @@ static void mdfour_tail(const unsigned char *in, int n) } } -void mdfour_update(struct mdfour *md, const unsigned char *in, int n) +void mdfour_update(struct mdfour *md, const unsigned char *in, size_t n) { uint32_t M[16]; @@ -149,7 +149,7 @@ void mdfour_update(struct mdfour *md, const unsigned char *in, int n) } if (md->tail_len) { - int len = 64 - md->tail_len; + size_t len = 64 - md->tail_len; if (len > n) len = n; memcpy(md->tail+md->tail_len, in, len); md->tail_len += len; diff --git a/mdfour.h b/mdfour.h index 302ac44c8..f2dc87155 100644 --- a/mdfour.h +++ b/mdfour.h @@ -22,17 +22,18 @@ #ifndef MDFOUR_H #define MDFOUR_H +#include #include struct mdfour { uint32_t A, B, C, D; - uint32_t totalN; + size_t totalN; unsigned char tail[64]; - unsigned tail_len; + size_t tail_len; }; void mdfour_begin(struct mdfour *md); -void mdfour_update(struct mdfour *md, const unsigned char *in, int n); +void mdfour_update(struct mdfour *md, const unsigned char *in, size_t n); void mdfour_result(struct mdfour *md, unsigned char *out); #endif diff --git a/unify.c b/unify.c index a5611c195..84ff093ea 100644 --- a/unify.c +++ b/unify.c @@ -102,7 +102,7 @@ static void build_table(void) static void pushchar(struct mdfour *hash, unsigned char c) { static unsigned char buf[64]; - static int len; + static size_t len; if (c == 0) { if (len > 0) {