[PATCH] Remove bogus warning in submodule link code

Dan McGee dpmcgee at gmail.com
Thu Jun 16 16:42:05 CEST 2011


In reality, len should ever be unset here if the conditions are right,
but there is insufficient info for the compiler to realize this so it
spits an error. Initialize len so gcc doesn't spit an error.

Signed-off-by: Dan McGee <dpmcgee at gmail.com>
---

Fixes:

    CC ui-shared.o
	ui-shared.c: In function ‘cgit_submodule_link’:
	ui-shared.c:559:7: warning: ‘len’ may be used uninitialized in this function [-Wuninitialized]

 ui-shared.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/ui-shared.c b/ui-shared.c
index 3150d48..ac3503c 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -523,7 +523,7 @@ void cgit_submodule_link(const char *class, char *path, const char *rev)
 	struct string_list *list;
 	struct string_list_item *item;
 	char tail, *dir;
-	size_t len;
+	size_t len = 0;
 
 	tail = 0;
 	list = &ctx.repo->submodules;
-- 
1.7.5.2





More information about the CGit mailing list