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

[PATCH] test-url-normalize.c: Fix gcc errors and sparse warnings

From
Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Date
Jul 24, 2013, 19:07 UTC
Message-ID
<51F0260B.5000905@ramsay1.demon.co.uk>

Sparse issues an "non-ANSI function declaration of function 'main'" warning when NO_CURL is set. In order to suppress the warning, we simply add the function prototype.

When NO_CURL and USE_CURL_MULTI are not defined, then gcc issues the following error:

      CC test-url-normalize.o
  test-url-normalize.c: In function `run_http_options':
  test-url-normalize.c:49: error: `max_requests' undeclared (first use in this function)
  test-url-normalize.c:49: error: (Each undeclared identifier is reported only once
  test-url-normalize.c:49: error: for each function it appears in.)
  make: *** [test-url-normalize.o] Error 1

In order to fix the error, we simply protect the use of the 'max_requests' variable with an preprocessor conditional.

Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
---
Hi Kyle,

When you next update the patches in your 'km/http-curl-config-per-url' branch, could you please squash this (or something like it) into the relevant patches.

Thanks!

ATB, Ramsay Jones

 test-url-normalize.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/test-url-normalize.c b/test-url-normalize.c
index abfa4eb..86ce553 100644
--- a/test-url-normalize.c
+++ b/test-url-normalize.c
@@ -1,6 +1,6 @@
 #ifdef NO_CURL
 
-int main()
+int main(void)
 {
 	return 125;
 }
@@ -45,8 +45,10 @@ static int run_http_options(const char *file,
 		printf("%s\n", curl_ssl_try ? "true" : "false");
 	else if (!strcmp("minsessions", opt_lc.buf))
 		printf("%d\n", min_curl_sessions);
+#ifdef USE_CURL_MULTI
 	else if (!strcmp("maxrequests", opt_lc.buf))
 		printf("%d\n", max_requests);
+#endif
 	else if (!strcmp("lowspeedlimit", opt_lc.buf))
 		printf("%ld\n", curl_low_speed_limit);
 	else if (!strcmp("lowspeedtime", opt_lc.buf))
-- 
1.8.3
Next: Kyle J. McKay
Message 1 of 19 in “test-url-normalize.c: Fix gcc errors and sparse warnings”
  1. test-url-normalize.c: Fix gcc errors and sparse warningsRamsay Jones, Jul 24, 2013
  2. Kyle J. McKayJul 24, 2013
  3. Junio C HamanoJul 24, 2013
  4. 0/3 "git config --get-urlmatch $section.$key $url"Junio C Hamano, Jul 29, 2013
  5. 1/3 url-match: split out URL matching logic out of http.cJunio C Hamano, Jul 29, 2013
  6. 2/3 builtin/config: refactor collect_config()Junio C Hamano, Jul 29, 2013
  7. 3/3 config: --get-urlmatchJunio C Hamano, Jul 29, 2013
  8. Jeff KingJul 30, 2013
  9. Junio C HamanoJul 30, 2013
  10. Jeff KingJul 30, 2013
  11. Junio C HamanoJul 30, 2013
  12. Kyle J. McKayJul 30, 2013
  13. 4/3 url-match: generalize configuration collection logicJunio C Hamano, Jul 30, 2013
  14. 5/3 revert most of the http_options() changeJunio C Hamano, Jul 30, 2013
  15. Kyle J. McKayJul 30, 2013
  16. Kyle J. McKayJul 30, 2013
  17. Junio C HamanoJul 30, 2013
  18. Ramsay JonesJul 31, 2013
  19. Junio C HamanoJul 31, 2013

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.