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

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.

Previous: Ævar Arnfjörð BjarmasonNext: Ævar Arnfjörð Bjarmason
Message 6 of 22 in “CodingGuidelines: various C99 updates”
  1. 0/5 CodingGuidelines: various C99 updatesÆvar Arnfjörð Bjarmason, Oct 7, 2022
  2. 1/5 CodingGuidelines: update for C99Ævar Arnfjörð Bjarmason, Oct 7, 2022
  3. Junio C HamanoOct 7, 2022
  4. 2/5 CodingGuidelines: mention dynamic C99 initializer elementsÆvar Arnfjörð Bjarmason, Oct 7, 2022
  5. 3/5 CodingGuidelines: allow declaring variables in for loopsÆvar Arnfjörð Bjarmason, Oct 7, 2022
  6. Junio C HamanoOct 7, 2022
  7. 4/5 CodingGuidelines: mention C99 features we can't useÆvar Arnfjörð Bjarmason, Oct 7, 2022
  8. Junio C HamanoOct 7, 2022
  9. 5/5 CodingGuidelines: recommend against unportable C99 struct syntaxÆvar Arnfjörð Bjarmason, Oct 7, 2022
  10. Junio C HamanoOct 7, 2022
  11. Junio C HamanoOct 7, 2022
  12. 0/5 CodingGUidelines: C99 updatesJunio C Hamano, Oct 10, 2022
  13. 1/5 CodingGuidelines: update for C99Junio C Hamano, Oct 10, 2022
  14. 2/5 CodingGuidelines: mention dynamic C99 initializer elementsJunio C Hamano, Oct 10, 2022
  15. 3/5 CodingGuidelines: allow declaring variables in for loopsJunio C Hamano, Oct 10, 2022
  16. 4/5 CodingGuidelines: mention C99 features we can't useJunio C Hamano, Oct 10, 2022
  17. 5/5 CodingGuidelines: recommend against unportable C99 struct syntaxJunio C Hamano, Oct 10, 2022
  18. Jeff KingOct 11, 2022
  19. Junio C HamanoOct 11, 2022
  20. Jeff KingOct 11, 2022
  21. Ævar Arnfjörð BjarmasonOct 11, 2022
  22. Junio C HamanoOct 11, 2022

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.