git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Sparse fixes for http-fetch
@ 2005-10-13 17:42 Peter Hagervall
  2005-10-13 17:51 ` H. Peter Anvin
  2005-10-13 18:16 ` Junio C Hamano
  0 siblings, 2 replies; 3+ messages in thread
From: Peter Hagervall @ 2005-10-13 17:42 UTC (permalink / raw)
  To: junkio; +Cc: git

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?

---

 * ANSI:fy a few function definitions
 * Make needlessly global functions static
 * Move variable declarations to beginning of enclosing block

Signed-off-by: Peter Hagervall <hager@cs.umu.se>

---

diff --git a/http-fetch.c b/http-fetch.c
index 0aba891..f2d0e0a 100644
--- a/http-fetch.c
+++ b/http-fetch.c
@@ -143,7 +143,7 @@ void process_curl_messages();
 void process_request_queue();
 #endif
 
-struct active_request_slot *get_active_slot()
+static struct active_request_slot *get_active_slot(void)
 {
 	struct active_request_slot *slot = active_queue_head;
 	struct active_request_slot *newslot;
@@ -192,7 +192,7 @@ struct active_request_slot *get_active_s
 	return slot;
 }
 
-int start_active_slot(struct active_request_slot *slot)
+static int start_active_slot(struct active_request_slot *slot)
 {
 #ifdef USE_CURL_MULTI
 	CURLMcode curlm_result = curl_multi_add_handle(curlm, slot->curl);
@@ -207,7 +207,7 @@ int start_active_slot(struct active_requ
 	return 1;
 }
 
-void run_active_slot(struct active_request_slot *slot)
+static void run_active_slot(struct active_request_slot *slot)
 {
 #ifdef USE_CURL_MULTI
 	int num_transfers;
@@ -255,7 +255,7 @@ void run_active_slot(struct active_reque
 #endif
 }
 
-void start_request(struct transfer_request *request)
+static void start_request(struct transfer_request *request)
 {
 	char *hex = sha1_to_hex(request->sha1);
 	char prevfile[PATH_MAX];
@@ -381,7 +381,7 @@ void start_request(struct transfer_reque
 	request->state = ACTIVE;
 }
 
-void finish_request(struct transfer_request *request)
+static void finish_request(struct transfer_request *request)
 {
 	fchmod(request->local, 0444);
 	close(request->local);
@@ -409,7 +409,7 @@ void finish_request(struct transfer_requ
 		pull_say("got %s\n", sha1_to_hex(request->sha1));
 }
 
-void release_request(struct transfer_request *request)
+static void release_request(struct transfer_request *request)
 {
 	struct transfer_request *entry = request_queue_head;
 
@@ -427,7 +427,7 @@ void release_request(struct transfer_req
 }
 
 #ifdef USE_CURL_MULTI
-void process_curl_messages()
+void process_curl_messages(void)
 {
 	int num_messages;
 	struct active_request_slot *slot;
@@ -479,7 +479,7 @@ void process_curl_messages()
 	}
 }
 
-void process_request_queue()
+void process_request_queue(void)
 {
 	struct transfer_request *request = request_queue_head;
 	int num_transfers;
@@ -875,6 +875,9 @@ static int fetch_object(struct alt_base 
 	char *hex = sha1_to_hex(sha1);
 	int ret;
 	struct transfer_request *request = request_queue_head;
+#ifdef USE_CURL_MULTI
+	int num_transfers;
+#endif
 
 	while (request != NULL && memcmp(request->sha1, sha1, 20))
 		request = request->next;
@@ -887,7 +890,6 @@ static int fetch_object(struct alt_base 
 	}
 
 #ifdef USE_CURL_MULTI
-	int num_transfers;
 	while (request->state == WAITING) {
 		curl_multi_perform(curlm, &num_transfers);
 		if (num_transfers < active_requests) {
@@ -1052,6 +1054,9 @@ int main(int argc, char **argv)
 	char *url;
 	int arg = 1;
 	struct active_request_slot *slot;
+#ifdef USE_CURL_MULTI
+	char *http_max_requests;
+#endif
 
 	while (arg < argc && argv[arg][0] == '-') {
 		if (argv[arg][1] == 't') {
@@ -1082,7 +1087,7 @@ int main(int argc, char **argv)
 	curl_global_init(CURL_GLOBAL_ALL);
 
 #ifdef USE_CURL_MULTI
-	char *http_max_requests = getenv("GIT_HTTP_MAX_REQUESTS");
+	http_max_requests = getenv("GIT_HTTP_MAX_REQUESTS");
 	if (http_max_requests != NULL)
 		max_requests = atoi(http_max_requests);
 	if (max_requests < 1)

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-10-13 18:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-10-13 17:42 [PATCH] Sparse fixes for http-fetch Peter Hagervall
2005-10-13 17:51 ` H. Peter Anvin
2005-10-13 18:16 ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).