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)