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

[PATCH v2 4/4] Silence false-positive maybe-uninitialized warnings found by gcc 9 -flto

From
Stephan Beyer <s-beyer@gmx.net>
Date
Sep 5, 2019, 22:48 UTC
Message-ID
<20190905224833.24913-4-s-beyer@gmx.net>
In-Reply-To
<20190905224833.24913-1-s-beyer@gmx.net>

gcc 9.2.1 with -flto flag suspects some uninitialized variables which become initialized in every code path where they are used. These false positives are "fixed" by this patch in the most naïve way.

This allows to compile git with gcc 9, link-time optimization, and using the DEVELOPER=1 switch (which sets -Werror).

Signed-off-by: Stephan Beyer <s-beyer@gmx.net>
---
 bulk-checkin.c | 2 ++
 fast-import.c  | 3 ++-
 2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/bulk-checkin.c b/bulk-checkin.c
index 39ee7d6107..87fa28c227 100644
--- a/bulk-checkin.c
+++ b/bulk-checkin.c
@@ -200,6 +200,8 @@ static int deflate_to_pack(struct bulk_checkin_state *state,
 	struct hashfile_checkpoint checkpoint;
 	struct pack_idx_entry *idx = NULL;

+	checkpoint.offset = 0;
+
 	seekback = lseek(fd, 0, SEEK_CUR);
 	if (seekback == (off_t) -1)
 		return error("cannot find the current offset");
diff --git a/fast-import.c b/fast-import.c
index b44d6a467e..58f73f9105 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -903,7 +903,8 @@ static int store_object(
 	struct object_entry *e;
 	unsigned char hdr[96];
 	struct object_id oid;
-	unsigned long hdrlen, deltalen;
+	unsigned long hdrlen;
+	unsigned long deltalen = 0;
 	git_hash_ctx c;
 	git_zstream s;

--
2.23.0.43.g31ebfd7ae6.dirty
Previous: Stephan BeyerNext: Stephan Beyer
Message 4 of 5 in “am: fail if no author line is given in --rebasing mode”
  1. 1/4 am: fail if no author line is given in --rebasing modeStephan Beyer, Sep 5, 2019
  2. 3/4 pack-objects: fix maybe-uninitialized warning for index_posStephan Beyer, Sep 5, 2019
  3. 2/4 test-read-cache: fix maybe-uninitialized warning for namelenStephan Beyer, Sep 5, 2019
  4. 4/4 Silence false-positive maybe-uninitialized warnings found by gcc 9 -fltoStephan Beyer, Sep 5, 2019
  5. Stephan BeyerSep 6, 2019

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.