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

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

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 11, 2013, 22:25 UTC
Message-ID
<xmqq1u2mlgop.fsf@gitster.dls.corp.google.com>
In-Reply-To
<xmqqeh6w131e.fsf@gitster.dls.corp.google.com>
Junio C Hamano <gitster@pobox.com> writes:
Show 11 quoted lines
>> 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)
Previous: Junio C HamanoNext: Torstein Hegge
Message 7 of 9 in “What's cooking in git.git (Nov 2013, #01; Fri, 1)”
  1. Junio C HamanoNov 1, 2013
  2. Thomas RastNov 1, 2013
  3. Junio C HamanoNov 4, 2013
  4. Michael HaggertyNov 13, 2013
  5. Ramsay JonesNov 1, 2013
  6. Junio C HamanoNov 4, 2013
  7. Junio C HamanoNov 11, 2013
  8. Torstein HeggeNov 3, 2013
  9. Junio C HamanoNov 4, 2013

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.