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

[PATCH 07/14] fast-import.c: Initialise variables to suppress msvc warnings

From
Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Date
Dec 4, 2010, 19:06 UTC
Message-ID
<4CFA913C.8000204@ramsay1.demon.co.uk>

The msvc compiler thinks that three variables could be used while uninitialised and issues the following warnings:

    ...\git\fast-import.c(2474) : warning C4700: uninitialized local \
        variable 'e' used
    ...\git\fast-import.c(2314) : warning C4700: uninitialized local \
        variable 'oe' used
    ...\git\fast-import.c(2151) : warning C4700: uninitialized local \
        variable 'oe' used

In order to suppress the warnings, we simply initialise all three of the pointer variables to NULL.

Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
---
 fast-import.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/fast-import.c b/fast-import.c
index 8263dbe..1d7cd03 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -2148,7 +2148,7 @@ static void file_change_m(struct branch *b)
 	const char *p = command_buf.buf + 2;
 	static struct strbuf uq = STRBUF_INIT;
 	const char *endp;
-	struct object_entry *oe = oe;
+	struct object_entry *oe = NULL;
 	unsigned char sha1[20];
 	uint16_t mode, inline_data = 0;
 
@@ -2311,7 +2311,7 @@ static void note_change_n(struct branch *b, unsigned char old_fanout)
 {
 	const char *p = command_buf.buf + 2;
 	static struct strbuf uq = STRBUF_INIT;
-	struct object_entry *oe = oe;
+	struct object_entry *oe = NULL;
 	struct branch *s;
 	unsigned char sha1[20], commit_sha1[20];
 	char path[60];
@@ -2471,7 +2471,7 @@ static int parse_from(struct branch *b)
 
 static struct hash_list *parse_merge(unsigned int *count)
 {
-	struct hash_list *list = NULL, *n, *e = e;
+	struct hash_list *list = NULL, *n, *e = NULL;
 	const char *from;
 	struct branch *s;
 
-- 
1.7.3
Message 1 of 1 in “fast-import.c: Initialise variables to suppress msvc warnings”
  1. 07/14 fast-import.c: Initialise variables to suppress msvc warningsRamsay Jones, Dec 4, 2010

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.