From 06ed8a3ec94d6770a62534a820cec441f90905f0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Sat, 2 Apr 2016 17:46:49 -0400 Subject: [PATCH] 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/parse-util.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/basic/parse-util.h b/src/basic/parse-util.h index 49184ecc3..9b1aebdb5 100644 --- a/src/basic/parse-util.h +++ b/src/basic/parse-util.h @@ -93,6 +93,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); -- 2.30.2