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

[PATCH v1 5/6] refs/debug: declare file-local variable to be static

From
Ben Boeckel <mathstuf@gmail.com>
Date
Jul 31, 2021, 02:42 UTC
Message-ID
<20210731024221.2113906-6-mathstuf@gmail.com>
In-Reply-To
<20210731024221.2113906-1-mathstuf@gmail.com>

Declaring a variable in a source file as `extern` and then defining it later is not very useful. It can instead be declared as `static`.

Signed-off-by: Ben Boeckel <mathstuf@gmail.com>
---
 refs/debug.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/refs/debug.c b/refs/debug.c
index 7db4abccc3..f5609408f3 100644
--- a/refs/debug.c
+++ b/refs/debug.c
@@ -9,7 +9,7 @@ struct debug_ref_store {
 	struct ref_store *refs;
 };
 
-extern struct ref_storage_be refs_be_debug;
+static struct ref_storage_be refs_be_debug;
 
 struct ref_store *maybe_debug_wrap_ref_store(const char *gitdir, struct ref_store *store)
 {
@@ -413,7 +413,7 @@ static int debug_reflog_expire(struct ref_store *ref_store, const char *refname,
 	return res;
 }
 
-struct ref_storage_be refs_be_debug = {
+static struct ref_storage_be refs_be_debug = {
 	NULL,
 	"debug",
 	NULL,
-- 
2.31.1
Previous: Ben BoeckelNext: Ben Boeckel
Message 6 of 7 in “globals: clean up some global usages”
  1. 0/6 globals: clean up some global usagesBen Boeckel, Jul 31, 2021
  2. 1/6 branch: move `git_default_branch_config` to `branch.c`Ben Boeckel, Jul 31, 2021
  3. 3/6 apply: move `apply_default_*whitespace` to `apply.c`Ben Boeckel, Jul 31, 2021
  4. 2/6 mailmap: move `git_default_mailmap_config` to `mailmap.c`Ben Boeckel, Jul 31, 2021
  5. 4/6 config: remove `core_compression_level`Ben Boeckel, Jul 31, 2021
  6. 5/6 refs/debug: declare file-local variable to be staticBen Boeckel, Jul 31, 2021
  7. 6/6 globals: remove explicit `0` initialization from globalsBen Boeckel, Jul 31, 2021

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.