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

Fix sparse warnings

From
Linus Torvalds <torvalds@osdl.org>
Date
Aug 1, 2005, 19:11 UTC
Message-ID
<Pine.LNX.4.58.0508011208280.3341@g5.osdl.org>

A few sparse warnings have crept in again since I checked last time: undeclared variables with global scope.

Fix them by marking the private variables properly "static".
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
----
Btw, sparse also warns about the "return 0" in receive-pack.c: unpack(), 
since that function is supposed to return void. I think somebody else 
already sent a patch for that one.
diff --git a/daemon.c b/daemon.c
--- a/daemon.c
+++ b/daemon.c
@@ -71,13 +71,13 @@ static int max_connections = 25;
 
 /* These are updated by the signal handler */
 static volatile unsigned int children_reaped = 0;
-pid_t dead_child[MAX_CHILDREN];
+static pid_t dead_child[MAX_CHILDREN];
 
 /* These are updated by the main loop */
 static unsigned int children_spawned = 0;
 static unsigned int children_deleted = 0;
 
-struct child {
+static struct child {
 	pid_t pid;
 	socklen_t addrlen;
 	struct sockaddr_storage address;
diff --git a/rev-cache.c b/rev-cache.c
--- a/rev-cache.c
+++ b/rev-cache.c
@@ -5,7 +5,7 @@
 struct rev_cache **rev_cache;
 int nr_revs, alloc_revs;
 
-struct rev_list_elem *rle_free;
+static struct rev_list_elem *rle_free;
 
 #define BATCH_SIZE 512
 
diff --git a/server-info.c b/server-info.c
--- a/server-info.c
+++ b/server-info.c
@@ -62,7 +62,7 @@ static int update_info_refs(int force)
 }
 
 /* packs */
-struct pack_info {
+static struct pack_info {
 	unsigned long latest;
 	struct packed_git *p;
 	int old_num;
Message 1 of 1 in “Fix sparse warnings”
  1. Linus TorvaldsAug 1, 2005

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.