Skip to content

Commit f5dce80

Browse files
Peter HagervallJunio C Hamano
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f6b42a8 commit f5dce80

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

http-fetch.c

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -219,11 +219,11 @@ static size_t fwrite_sha1_file(void *ptr, size_t eltsize, size_t nmemb,
219219
}
220220

221221
#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);
224224
#endif
225225

226-
static CURL* get_curl_handle()
226+
static CURL* get_curl_handle(void)
227227
{
228228
CURL* result = curl_easy_init();
229229

@@ -249,7 +249,7 @@ static CURL* get_curl_handle()
249249
return result;
250250
}
251251

252-
struct active_request_slot *get_active_slot()
252+
static struct active_request_slot *get_active_slot(void)
253253
{
254254
struct active_request_slot *slot = active_queue_head;
255255
struct active_request_slot *newslot;
@@ -302,7 +302,7 @@ struct active_request_slot *get_active_slot()
302302
return slot;
303303
}
304304

305-
int start_active_slot(struct active_request_slot *slot)
305+
static int start_active_slot(struct active_request_slot *slot)
306306
{
307307
#ifdef USE_CURL_MULTI
308308
CURLMcode curlm_result = curl_multi_add_handle(curlm, slot->curl);
@@ -317,7 +317,7 @@ int start_active_slot(struct active_request_slot *slot)
317317
return 1;
318318
}
319319

320-
void run_active_slot(struct active_request_slot *slot)
320+
static void run_active_slot(struct active_request_slot *slot)
321321
{
322322
#ifdef USE_CURL_MULTI
323323
int num_transfers;
@@ -365,7 +365,7 @@ void run_active_slot(struct active_request_slot *slot)
365365
#endif
366366
}
367367

368-
void start_request(struct transfer_request *request)
368+
static void start_request(struct transfer_request *request)
369369
{
370370
char *hex = sha1_to_hex(request->sha1);
371371
char prevfile[PATH_MAX];
@@ -491,7 +491,7 @@ void start_request(struct transfer_request *request)
491491
request->state = ACTIVE;
492492
}
493493

494-
void finish_request(struct transfer_request *request)
494+
static void finish_request(struct transfer_request *request)
495495
{
496496
fchmod(request->local, 0444);
497497
close(request->local);
@@ -519,7 +519,7 @@ void finish_request(struct transfer_request *request)
519519
pull_say("got %s\n", sha1_to_hex(request->sha1));
520520
}
521521

522-
void release_request(struct transfer_request *request)
522+
static void release_request(struct transfer_request *request)
523523
{
524524
struct transfer_request *entry = request_queue_head;
525525

@@ -537,7 +537,7 @@ void release_request(struct transfer_request *request)
537537
}
538538

539539
#ifdef USE_CURL_MULTI
540-
void process_curl_messages()
540+
void process_curl_messages(void)
541541
{
542542
int num_messages;
543543
struct active_request_slot *slot;
@@ -589,7 +589,7 @@ void process_curl_messages()
589589
}
590590
}
591591

592-
void process_request_queue()
592+
void process_request_queue(void)
593593
{
594594
struct transfer_request *request = request_queue_head;
595595
int num_transfers;
@@ -1010,8 +1010,8 @@ static int fetch_object(struct alt_base *repo, unsigned char *sha1)
10101010
}
10111011

10121012
#ifdef USE_CURL_MULTI
1013-
int num_transfers;
10141013
while (request->state == WAITING) {
1014+
int num_transfers;
10151015
curl_multi_perform(curlm, &num_transfers);
10161016
if (num_transfers < active_requests) {
10171017
process_curl_messages();
@@ -1207,9 +1207,11 @@ int main(int argc, char **argv)
12071207
curl_global_init(CURL_GLOBAL_ALL);
12081208

12091209
#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+
}
12131215

12141216
curlm = curl_multi_init();
12151217
if (curlm == NULL) {

0 commit comments

Comments
 (0)