diff mbox series

[4/3] index-pack: work around false positive use of uninitialized variable

Message ID xmqqr06o3vid.fsf_-_@gitster.g (mailing list archive)
State New
Headers show
Series Performance improvements for repacking non-promisor objects | expand

Commit Message

Junio C Hamano Dec. 4, 2024, 4:46 a.m. UTC
The base_name variable in this function is given a value if cmd.args
array is not empty (i.e., if we run the pack-objects command), and
the function returns when cmd.args is empty before hitting a call to
free(base_name) near the end of the function, so to a human reader,
it can be seen that the variable is not used uninitialized, but to a
semi-intelligent compiler it is not so clear.

Squelch a false positive by a meaningless NULL initialization.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---

 * Tentatively queued to unblock CI.  There may be breakages due to
   other topics in flight, but at least this one is easy to resolve
   (hopefully---I haven't pushed it out).

   https://github.com/git/git/actions/runs/12152173257

 builtin/index-pack.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/builtin/index-pack.c b/builtin/index-pack.c
index 1594f2b81d..8e600a58bf 100644
--- a/builtin/index-pack.c
+++ b/builtin/index-pack.c
@@ -1803,7 +1803,7 @@  static void repack_local_links(void)
 	struct strbuf line = STRBUF_INIT;
 	struct oidset_iter iter;
 	struct object_id *oid;
-	char *base_name;
+	char *base_name = NULL;
 
 	if (!oidset_size(&outgoing_links))
 		return;