From: Niels Möller Date: Fri, 5 Aug 2016 08:42:24 +0000 (+0200) Subject: Helper read_file: Use size_t for sizes, and uint8_t for the contents. X-Git-Tag: nettle_3.3_release_20161001~46 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=748e2c549b93834c0fb03f9f8d11ec45a3459e31;p=thirdparty%2Fnettle.git Helper read_file: Use size_t for sizes, and uint8_t for the contents. --- diff --git a/ChangeLog b/ChangeLog index 84710c46..0de71fe0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2016-08-05 Niels Möller + + * examples/io.c (read_file): Use size_t for sizes, and uint8_t for + the contents. + 2016-08-04 Niels Möller * dsa-sign.c (dsa_sign): Return failure if p is even, so that an diff --git a/examples/io.c b/examples/io.c index 52fc54e2..7651cedc 100644 --- a/examples/io.c +++ b/examples/io.c @@ -74,11 +74,11 @@ werror(const char *format, ...) } } -unsigned -read_file(const char *name, unsigned max_size, char **contents) +size_t +read_file(const char *name, size_t max_size, uint8_t **contents) { - unsigned size, done; - char *buffer; + size_t size, done; + uint8_t *buffer; FILE *f; f = fopen(name, "rb"); @@ -92,7 +92,7 @@ read_file(const char *name, unsigned max_size, char **contents) for (buffer = NULL, done = 0;; size *= 2) { - char *p; + uint8_t *p; if (max_size && size > max_size) size = max_size; @@ -167,7 +167,7 @@ int simple_random(struct yarrow256_ctx *ctx, const char *name) { unsigned length; - char *buffer; + uint8_t *buffer; if (name) length = read_file(name, 0, &buffer); diff --git a/examples/io.h b/examples/io.h index 6d4e4611..e4bb1cf7 100644 --- a/examples/io.h +++ b/examples/io.h @@ -52,8 +52,8 @@ werror(const char *format, ...) PRINTF_STYLE(1, 2); * treated as an error; return value is zero, and no space is * allocated. The returned data is NUL-terminated, for convenience. */ -unsigned -read_file(const char *name, unsigned size, char **buffer); +size_t +read_file(const char *name, size_t size, uint8_t **buffer); int write_file(const char *name, unsigned size, const char *buffer); diff --git a/examples/read_rsa_key.c b/examples/read_rsa_key.c index 4647d686..f225666b 100644 --- a/examples/read_rsa_key.c +++ b/examples/read_rsa_key.c @@ -47,7 +47,7 @@ read_rsa_key(const char *name, struct rsa_private_key *priv) { unsigned length; - char *buffer; + uint8_t *buffer; int res; length = read_file(name, 0, &buffer); diff --git a/examples/rsa-verify.c b/examples/rsa-verify.c index f612c6de..297903e2 100644 --- a/examples/rsa-verify.c +++ b/examples/rsa-verify.c @@ -44,7 +44,7 @@ static int read_signature(const char *name, mpz_t s) { - char *buffer; + uint8_t *buffer; unsigned length; int res; @@ -52,7 +52,7 @@ read_signature(const char *name, mpz_t s) if (!length) return 0; - res = (mpz_set_str(s, buffer, 16) == 0); + res = (mpz_set_str(s, (const char *) buffer, 16) == 0); free(buffer); return res;