[PATCH v1 2/2] curl_off_t xcurl_off_t is not portable
- From
tboegi@web.de <tboegi@web.de>
- Date
- Oct 25, 2018, 16:13 UTC
- Message-ID
- <20181025161310.29249-1-tboegi@web.de>
From: Torsten Bögershausen <tboegi@web.de>
Comparing signed and unsigned values is not always portable. When setting DEVELOPER = 1 DEVOPTS = extra-all
"gcc (Raspbian 6.3.0-18+rpi1+deb9u1) 6.3.0 20170516" errors out with "comparison is always false due to limited range of data type" "[-Werror=type-limits]"
Solution: Use a valid cast & compare, similar to xsize_t()
Signed-off-by: Torsten Bögershausen <tboegi@web.de> --- remote-curl.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/remote-curl.c b/remote-curl.c index 762a55a75f..c89fd6d1c3 100644 --- a/remote-curl.c +++ b/remote-curl.c @@ -618,9 +618,10 @@ static int probe_rpc(struct rpc_state *rpc, struct slot_results *results) } static curl_off_t xcurl_off_t(ssize_t len) { - if (len > maximum_signed_value_of_type(curl_off_t)) + curl_off_t size = (curl_off_t) len; + if (len != (ssize_t) size) die("cannot handle pushes this big"); - return (curl_off_t) len; + return size; } static int post_rpc(struct rpc_state *rpc)
-- 2.11.0