Thread (2 messages) flat view 2 messages, 1 author, 2016-06-15

Re: What's cooking in git.git (Nov 2013, #01; Fri, 1)

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:59:13
Subsystem: the rest · Maintainer: Linus Torvalds

Possibly related (same subject, not in this thread)

Junio C Hamano [off-list ref] writes:
quoted
Commit ad24a30ef ("fast-export: add new --refspec option", 31-10-2013)
causes sparse to complain:

      SP builtin/fast-export.c
  builtin/fast-export.c:739:55: warning: Variable length array is used.

Do we want to use this C99 feature?
Good eyes, and no---this needs to be fixed before going forward.

Thanks for spotting.
I'm tempted to squash this in to the problematic commit, if nobody
comes up with a better fix soonish, before merging the series to
'next'.

 builtin/fast-export.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/builtin/fast-export.c b/builtin/fast-export.c
index 8ed41b4..7d02f63 100644
--- a/builtin/fast-export.c
+++ b/builtin/fast-export.c
@@ -736,9 +736,10 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix)
 		usage_with_options (fast_export_usage, options);
 
 	if (refspecs_list.nr) {
-		const char *refspecs_str[refspecs_list.nr];
+		const char **refspecs_str;
 		int i;
 
+		refspecs_str = xmalloc(sizeof(const char *) * refspecs_list.nr);
 		for (i = 0; i < refspecs_list.nr; i++)
 			refspecs_str[i] = refspecs_list.items[i].string;
 
@@ -746,6 +747,7 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix)
 		refspecs = parse_fetch_refspec(refspecs_nr, refspecs_str);
 
 		string_list_clear(&refspecs_list, 1);
+		free(refspecs_str);
 	}
 
 	if (use_done_feature)
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help