@matheusbsbs / matheus-bagliano / commits / f5dce80611
Fork 0

Sparse fixes for http-fetch

This patch cleans out all sparse warnings from http-fetch.c I'm a bit uncomfortable with adding extra #ifdefs to avoid either 'mixing declaration with code' or 'unused variable' warnings, but I figured that since those functions are already littered with #ifdefs I might just get away with it. Comments? [jc: I adjusted Peter's patch to address uncomfortableness issues.] Signed-off-by: Peter Hagervall <hager@cs.umu.se> Signed-off-by: Junio C Hamano <junkio@cox.net>

Peter Hagervall committed Oct 16, 2005 at 00:01 UTC f5dce80611ed865d2d5d1e76c2c3ae64bf99fe99
1 file changed +17 -15
http-fetch.c
+17 -15
@@ -219,11 +219,11 @@ static size_t fwrite_sha1_file(void *ptr, size_t eltsize, size_t nmemb,
219 }
220
221 #ifdef USE_CURL_MULTI
222 -void process_curl_messages();
223 -void process_request_queue();
222 +static void process_curl_messages(void);
223 +static void process_request_queue(void);
224 #endif
225
226 -static CURL* get_curl_handle()
226 +static CURL* get_curl_handle(void)
227 {
228 CURL* result = curl_easy_init();
229
@@ -249,7 +249,7 @@ static CURL* get_curl_handle()
249 return result;
250 }
251
252 -struct active_request_slot *get_active_slot()
252 +static struct active_request_slot *get_active_slot(void)
253 {
254 struct active_request_slot *slot = active_queue_head;
255 struct active_request_slot *newslot;
@@ -302,7 +302,7 @@ struct active_request_slot *get_active_slot()
302 return slot;
303 }
304
305 -int start_active_slot(struct active_request_slot *slot)
305 +static int start_active_slot(struct active_request_slot *slot)
306 {
307 #ifdef USE_CURL_MULTI
308 CURLMcode curlm_result = curl_multi_add_handle(curlm, slot->curl);
@@ -317,7 +317,7 @@ int start_active_slot(struct active_request_slot *slot)
317 return 1;
318 }
319
320 -void run_active_slot(struct active_request_slot *slot)
320 +static void run_active_slot(struct active_request_slot *slot)
321 {
322 #ifdef USE_CURL_MULTI
323 int num_transfers;
@@ -365,7 +365,7 @@ void run_active_slot(struct active_request_slot *slot)
365 #endif
366 }
367
368 -void start_request(struct transfer_request *request)
368 +static void start_request(struct transfer_request *request)
369 {
370 char *hex = sha1_to_hex(request->sha1);
371 char prevfile[PATH_MAX];
@@ -491,7 +491,7 @@ void start_request(struct transfer_request *request)
491 request->state = ACTIVE;
492 }
493
494 -void finish_request(struct transfer_request *request)
494 +static void finish_request(struct transfer_request *request)
495 {
496 fchmod(request->local, 0444);
497 close(request->local);
@@ -519,7 +519,7 @@ void finish_request(struct transfer_request *request)
519 pull_say("got %s\n", sha1_to_hex(request->sha1));
520 }
521
522 -void release_request(struct transfer_request *request)
522 +static void release_request(struct transfer_request *request)
523 {
524 struct transfer_request *entry = request_queue_head;
525
@@ -537,7 +537,7 @@ void release_request(struct transfer_request *request)
537 }
538
539 #ifdef USE_CURL_MULTI
540 -void process_curl_messages()
540 +void process_curl_messages(void)
541 {
542 int num_messages;
543 struct active_request_slot *slot;
@@ -589,7 +589,7 @@ void process_curl_messages()
589 }
590 }
591
592 -void process_request_queue()
592 +void process_request_queue(void)
593 {
594 struct transfer_request *request = request_queue_head;
595 int num_transfers;
@@ -1010,8 +1010,8 @@ static int fetch_object(struct alt_base *repo, unsigned char *sha1)
1010 }
1011
1012 #ifdef USE_CURL_MULTI
1013 - int num_transfers;
1013 while (request->state == WAITING) {
1014 + int num_transfers;
1015 curl_multi_perform(curlm, &num_transfers);
1016 if (num_transfers < active_requests) {
1017 process_curl_messages();
@@ -1207,9 +1207,11 @@ int main(int argc, char **argv)
1207 curl_global_init(CURL_GLOBAL_ALL);
1208
1209 #ifdef USE_CURL_MULTI
1210 - char *http_max_requests = getenv("GIT_HTTP_MAX_REQUESTS");
1211 - if (http_max_requests != NULL)
1212 - max_requests = atoi(http_max_requests);
1210 + {
1211 + char *http_max_requests = getenv("GIT_HTTP_MAX_REQUESTS");
1212 + if (http_max_requests != NULL)
1213 + max_requests = atoi(http_max_requests);
1214 + }
1215
1216 curlm = curl_multi_init();
1217 if (curlm == NULL) {