Re: [PATCH 3/5] CodingGuidelines: allow declaring variables in for loops
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Oct 7, 2022, 18:12 UTC
- Message-ID
- <xmqq5ygvfqp3.fsf@gitster.g>
- In-Reply-To
- <patch-3.5-80afc246666-20221007T092505Z-avarab@gmail.com>
Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
Show 18 quoted lines
> diff --git a/revision.c b/revision.c
> index 36e31942cee..8f2623b3b5a 100644
> --- a/revision.c
> +++ b/revision.c
> @@ -47,13 +47,6 @@ static inline int want_ancestry(const struct rev_info *revs);
> void show_object_with_name(FILE *out, struct object *obj, const char *name)
> {
> fprintf(out, "%s ", oid_to_hex(&obj->oid));
> - /*
> - * This "for (const char *p = ..." is made as a first step towards
> - * making use of such declarations elsewhere in our codebase. If
> - * it causes compilation problems on your platform, please report
> - * it to the Git mailing list at git@vger.kernel.org. In the meantime,
> - * adding -std=gnu99 to CFLAGS may help if you are with older GCC.
> - */
> for (const char *p = name; *p && *p != '\n'; p++)
> fputc(*p, out);
> fputc('\n', out);Good. Thanks for not forgetting to remove this.
Show 13 quoted lines
> diff --git a/t/helper/test-parse-options.c b/t/helper/test-parse-options.c
> index 506835521a4..f8a62d892d9 100644
> --- a/t/helper/test-parse-options.c
> +++ b/t/helper/test-parse-options.c
> @@ -195,8 +195,7 @@ int cmd__parse_options(int argc, const char **argv)
>
> static void print_args(int argc, const char **argv)
> {
> - int i;
> - for (i = 0; i < argc; i++)
> + for (int i = 0; i < argc; i++)
> printf("arg %02d: %s\n", i, argv[i]);
> }This does not belong to this patch. If the current code as written is acceptable, it is not worth patch churn to rewrite it.