git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[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
Next: Junio C Hamano
Message 1 of 8 in “curl_off_t xcurl_off_t is not portable”
  1. 2/2 curl_off_t xcurl_off_t is not portabletboegi@web.de, Oct 25, 2018
  2. Junio C HamanoOct 26, 2018
  3. Torsten BögershausenOct 26, 2018
  4. 1/1 remote-curl.c: xcurl_off_t is not portable (on 32 bit platfoms)tboegi@web.de, Oct 29, 2018
  5. 1/1 remote-curl.c: xcurl_off_t is not portable (on 32 bit platfoms)tboegi@web.de, Nov 9, 2018
  6. Junio C HamanoNov 12, 2018
  7. Torsten BögershausenNov 12, 2018
  8. Junio C HamanoNov 12, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.