{"thread":{"id":"2094","subject":"[PATCH] Sparse fixes for http-fetch","startedAt":"2005-10-13T17:42:03Z","lastAt":"2005-10-13T18:16:34Z","messageCount":3,"participants":["Peter Hagervall","H. Peter Anvin","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"10076","messageId":"20051013174203.GA6860@peppar.cs.umu.se","threadId":"2094","inReplyTo":null,"subject":"[PATCH] Sparse fixes for http-fetch","fromName":"Peter Hagervall","fromEmail":"hager@cs.umu.se","sentAt":"2005-10-13T17:42:03Z","receivedAt":"2005-10-13T17:42:03Z","isPatch":true,"sender":{"key":"hager@cs.umu.se","avatar":null},"body":"This patch cleans out all sparse warnings from http-fetch.c\n\nI'm a bit uncomfortable with adding extra #ifdefs to avoid either\n'mixing declaration with code' or 'unused variable' warnings, but I\nfigured that since those functions are already littered with #ifdefs I\nmight just get away with it. Comments?\n\n---\n\n * ANSI:fy a few function definitions\n * Make needlessly global functions static\n * Move variable declarations to beginning of enclosing block\n\nSigned-off-by: Peter Hagervall <hager@cs.umu.se>\n\n---\n\ndiff --git a/http-fetch.c b/http-fetch.c\nindex 0aba891..f2d0e0a 100644\n--- a/http-fetch.c\n+++ b/http-fetch.c\n@@ -143,7 +143,7 @@ void process_curl_messages();\n void process_request_queue();\n #endif\n \n-struct active_request_slot *get_active_slot()\n+static struct active_request_slot *get_active_slot(void)\n {\n \tstruct active_request_slot *slot = active_queue_head;\n \tstruct active_request_slot *newslot;\n@@ -192,7 +192,7 @@ struct active_request_slot *get_active_s\n \treturn slot;\n }\n \n-int start_active_slot(struct active_request_slot *slot)\n+static int start_active_slot(struct active_request_slot *slot)\n {\n #ifdef USE_CURL_MULTI\n \tCURLMcode curlm_result = curl_multi_add_handle(curlm, slot->curl);\n@@ -207,7 +207,7 @@ int start_active_slot(struct active_requ\n \treturn 1;\n }\n \n-void run_active_slot(struct active_request_slot *slot)\n+static void run_active_slot(struct active_request_slot *slot)\n {\n #ifdef USE_CURL_MULTI\n \tint num_transfers;\n@@ -255,7 +255,7 @@ void run_active_slot(struct active_reque\n #endif\n }\n \n-void start_request(struct transfer_request *request)\n+static void start_request(struct transfer_request *request)\n {\n \tchar *hex = sha1_to_hex(request->sha1);\n \tchar prevfile[PATH_MAX];\n@@ -381,7 +381,7 @@ void start_request(struct transfer_reque\n \trequest->state = ACTIVE;\n }\n \n-void finish_request(struct transfer_request *request)\n+static void finish_request(struct transfer_request *request)\n {\n \tfchmod(request->local, 0444);\n \tclose(request->local);\n@@ -409,7 +409,7 @@ void finish_request(struct transfer_requ\n \t\tpull_say(\"got %s\\n\", sha1_to_hex(request->sha1));\n }\n \n-void release_request(struct transfer_request *request)\n+static void release_request(struct transfer_request *request)\n {\n \tstruct transfer_request *entry = request_queue_head;\n \n@@ -427,7 +427,7 @@ void release_request(struct transfer_req\n }\n \n #ifdef USE_CURL_MULTI\n-void process_curl_messages()\n+void process_curl_messages(void)\n {\n \tint num_messages;\n \tstruct active_request_slot *slot;\n@@ -479,7 +479,7 @@ void process_curl_messages()\n \t}\n }\n \n-void process_request_queue()\n+void process_request_queue(void)\n {\n \tstruct transfer_request *request = request_queue_head;\n \tint num_transfers;\n@@ -875,6 +875,9 @@ static int fetch_object(struct alt_base \n \tchar *hex = sha1_to_hex(sha1);\n \tint ret;\n \tstruct transfer_request *request = request_queue_head;\n+#ifdef USE_CURL_MULTI\n+\tint num_transfers;\n+#endif\n \n \twhile (request != NULL && memcmp(request->sha1, sha1, 20))\n \t\trequest = request->next;\n@@ -887,7 +890,6 @@ static int fetch_object(struct alt_base \n \t}\n \n #ifdef USE_CURL_MULTI\n-\tint num_transfers;\n \twhile (request->state == WAITING) {\n \t\tcurl_multi_perform(curlm, &num_transfers);\n \t\tif (num_transfers < active_requests) {\n@@ -1052,6 +1054,9 @@ int main(int argc, char **argv)\n \tchar *url;\n \tint arg = 1;\n \tstruct active_request_slot *slot;\n+#ifdef USE_CURL_MULTI\n+\tchar *http_max_requests;\n+#endif\n \n \twhile (arg < argc && argv[arg][0] == '-') {\n \t\tif (argv[arg][1] == 't') {\n@@ -1082,7 +1087,7 @@ int main(int argc, char **argv)\n \tcurl_global_init(CURL_GLOBAL_ALL);\n \n #ifdef USE_CURL_MULTI\n-\tchar *http_max_requests = getenv(\"GIT_HTTP_MAX_REQUESTS\");\n+\thttp_max_requests = getenv(\"GIT_HTTP_MAX_REQUESTS\");\n \tif (http_max_requests != NULL)\n \t\tmax_requests = atoi(http_max_requests);\n \tif (max_requests < 1)\n"},{"id":"10077","messageId":"434E9EA1.3030002@zytor.com","threadId":"2094","inReplyTo":"20051013174203.GA6860@peppar.cs.umu.se","subject":"Re: [PATCH] Sparse fixes for http-fetch","fromName":"H. Peter Anvin","fromEmail":"hpa@zytor.com","sentAt":"2005-10-13T17:51:29Z","receivedAt":"2005-10-13T17:51:29Z","isPatch":true,"sender":{"key":"hpa@zytor.com","avatar":null},"body":"Peter Hagervall wrote:\n> This patch cleans out all sparse warnings from http-fetch.c\n> \n> I'm a bit uncomfortable with adding extra #ifdefs to avoid either\n> 'mixing declaration with code' or 'unused variable' warnings, but I\n> figured that since those functions are already littered with #ifdefs I\n> might just get away with it. Comments?\n> \n\nFor the first, you can use extra brackets to create blocks in which \ndeclarations can happen; for the latter, you can (void)var; to specify \nthat a certain variable may be legitimately unused under some circumstances.\n\n\t-hpa\n"},{"id":"10078","messageId":"7vd5m92sfx.fsf@assigned-by-dhcp.cox.net","threadId":"2094","inReplyTo":"20051013174203.GA6860@peppar.cs.umu.se","subject":"Re: [PATCH] Sparse fixes for http-fetch","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-10-13T18:16:34Z","receivedAt":"2005-10-13T18:16:34Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Peter Hagervall <hager@cs.umu.se> writes:\n\n> I'm a bit uncomfortable with adding extra #ifdefs to avoid either\n> 'mixing declaration with code' or 'unused variable' warnings, but I\n> figured that since those functions are already littered with #ifdefs I\n> might just get away with it. Comments?\n\nHow about something like this on top of what you posted?  There\nstill is one in main(), but... \n\n---\ncd /opt/packrat/playpen/public/in-place/git/git.junio/\ngit diff\ndiff --git a/http-fetch.c b/http-fetch.c\nindex 26f8130..d549471 100644\n--- a/http-fetch.c\n+++ b/http-fetch.c\n@@ -27,6 +27,8 @@ static int data_received;\n #ifdef USE_CURL_MULTI\n static int max_requests = DEFAULT_MAX_REQUESTS;\n static CURLM *curlm;\n+static void process_curl_messages();\n+static void process_request_queue();\n #endif\n static CURL *curl_default;\n static struct curl_slist *pragma_header;\n@@ -154,11 +156,6 @@ static size_t fwrite_sha1_file(void *ptr\n \treturn size;\n }\n \n-#ifdef USE_CURL_MULTI\n-void process_curl_messages();\n-void process_request_queue();\n-#endif\n-\n static struct active_request_slot *get_active_slot(void)\n {\n \tstruct active_request_slot *slot = active_queue_head;\n@@ -443,7 +440,7 @@ static void release_request(struct trans\n }\n \n #ifdef USE_CURL_MULTI\n-void process_curl_messages(void)\n+static void process_curl_messages(void)\n {\n \tint num_messages;\n \tstruct active_request_slot *slot;\n@@ -495,7 +492,7 @@ void process_curl_messages(void)\n \t}\n }\n \n-void process_request_queue(void)\n+static void process_request_queue(void)\n {\n \tstruct transfer_request *request = request_queue_head;\n \tint num_transfers;\n@@ -904,9 +901,6 @@ static int fetch_object(struct alt_base \n \tchar *hex = sha1_to_hex(sha1);\n \tint ret;\n \tstruct transfer_request *request = request_queue_head;\n-#ifdef USE_CURL_MULTI\n-\tint num_transfers;\n-#endif\n \n \twhile (request != NULL && memcmp(request->sha1, sha1, 20))\n \t\trequest = request->next;\n@@ -920,6 +914,7 @@ static int fetch_object(struct alt_base \n \n #ifdef USE_CURL_MULTI\n \twhile (request->state == WAITING) {\n+\t\tint num_transfers;\n \t\tcurl_multi_perform(curlm, &num_transfers);\n \t\tif (num_transfers < active_requests) {\n \t\t\tprocess_curl_messages();\n\nCompilation finished at Thu Oct 13 11:14:23\n"}]}