From 7c2da2ca8824693c7eeb83e4b22174c33b2a480a Mon Sep 17 00:00:00 2001 From: Zbigniew Jędrzejewski-Szmek Date: Sat, 2 Apr 2016 17:46:49 -0400 Subject: test-compress-benchmark: fix argument parsing on 32bit The patch is not minimal, but a function to parse size_t is probably going to come in handy in other places, so I think it's nicer to define a proper parsing function than to open-code the cast. --- src/basic/copy.c | 2 +- src/basic/parse-util.h | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) (limited to 'src/basic') diff --git a/src/basic/copy.c b/src/basic/copy.c index 41dc8ca79a..10c03a8b52 100644 --- a/src/basic/copy.c +++ b/src/basic/copy.c @@ -71,7 +71,7 @@ static ssize_t try_copy_file_range(int fd_in, loff_t *off_in, int copy_bytes(int fdf, int fdt, uint64_t max_bytes, bool try_reflink) { bool try_cfr = true, try_sendfile = true, try_splice = true; int r; - size_t m = SSIZE_MAX; /* that the maximum that sendfile and c_f_r accept */ + size_t m = SSIZE_MAX; /* that is the maximum that sendfile and c_f_r accept */ assert(fdf >= 0); assert(fdt >= 0); diff --git a/src/basic/parse-util.h b/src/basic/parse-util.h index d8dc26a36e..c407263e16 100644 --- a/src/basic/parse-util.h +++ b/src/basic/parse-util.h @@ -90,6 +90,18 @@ static inline int safe_atoli(const char *s, long int *ret_u) { } #endif +#if SIZE_MAX == UINT_MAX +static inline int safe_atozu(const char *s, size_t *ret_u) { + assert_cc(sizeof(size_t) == sizeof(unsigned)); + return safe_atou(s, ret_u); +} +#else +static inline int safe_atozu(const char *s, size_t *ret_u) { + assert_cc(sizeof(size_t) == sizeof(long unsigned)); + return safe_atolu(s, ret_u); +} +#endif + int safe_atod(const char *s, double *ret_d); int parse_fractional_part_u(const char **s, size_t digits, unsigned *res); -- cgit v1.2.3-54-g00ecf