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

Re: [PATCH 6/6] git-compat-util.h: add __attribute__((printf)) to git_*printf*

From
Jeff King <peff@peff.net>
Date
Jul 12, 2021, 21:45 UTC
Message-ID
<YOy33I+T0LsLHYoS@coredump.intra.peff.net>
In-Reply-To
<012b01d7775c$2ddcca60$89965f20$@nexbridge.com>
On Mon, Jul 12, 2021 at 04:26:16PM -0400, Randall S. Becker wrote:
Show 19 quoted lines
> >> In practice this is redundant to the compiler's default printf format
> >> checking, since we mostly (entirely?)  develop and test on platforms
> >> where SNPRINTF_RETURNS_BOGUS is not set. I'm doing this mainly for
> >> consistency with other code, now we don't need to think about why this
> >> particular case is different.
> >>
> >> See c4582f93a26 (Add compat/snprintf.c for systems that return bogus,
> >> 2008-03-05) for the commit that added these functions.
> >
> >I'm slightly lukewarm on general on adding this to a compat function.
> >Those are meant to be a lowest-common-denominator fallback, and we usually avoid fancy features or our usual styles there in favor of
> >simplicity.
> >
> >I guess this probably isn't _hurting_ anything, but it makes me wonder how many systems have a broken snprintf _and_ support the
> >attribute.
> 
> NonStop does not support __attribute__ on any compiler I know of. This
> appears to be a gcc extension, so compat.c would create a gcc
> dependency, which is also not on the platform. snprintf is in place.

We already turn __attribute__ into a noop on unsupported platforms early in git-compat-util.h (around line 443). So this would be OK, since the snprintf macro hackery is later in the file (around line 786).

-Peff
Previous: Randall S. BeckerNext: Randall S. Becker
Message 10 of 33 in “add missing __attribute__((format))”
  1. 0/6 add missing __attribute__((format))Ævar Arnfjörð Bjarmason, Jul 10, 2021
  2. 1/6 *.c static functions: don't forward-declare __attribute__Ævar Arnfjörð Bjarmason, Jul 10, 2021
  3. 3/6 *.c static functions: add missing __attribute__((format))Ævar Arnfjörð Bjarmason, Jul 10, 2021
  4. 5/6 bugreport.c: tweak cmd_bugreport() to use __attribute__((printf))Ævar Arnfjörð Bjarmason, Jul 10, 2021
  5. Junio C HamanoJul 12, 2021
  6. 2/6 sequencer.c: move static function to avoid forward declÆvar Arnfjörð Bjarmason, Jul 10, 2021
  7. 6/6 git-compat-util.h: add __attribute__((printf)) to git_*printf*Ævar Arnfjörð Bjarmason, Jul 10, 2021
  8. Jeff KingJul 12, 2021
  9. Randall S. BeckerJul 12, 2021
  10. Jeff KingJul 12, 2021
  11. Randall S. BeckerJul 12, 2021
  12. 4/6 *.h: add a few missing __attribute__((format))Ævar Arnfjörð Bjarmason, Jul 10, 2021
  13. Ævar Arnfjörð BjarmasonJul 11, 2021
  14. Jeff KingJul 12, 2021
  15. Jeff KingJul 12, 2021
  16. 0/6 add missing __attribute__((format))Ævar Arnfjörð Bjarmason, Jul 13, 2021
  17. 1/6 *.c static functions: don't forward-declare __attribute__Ævar Arnfjörð Bjarmason, Jul 13, 2021
  18. 2/6 sequencer.c: move static function to avoid forward declÆvar Arnfjörð Bjarmason, Jul 13, 2021
  19. 3/6 *.c static functions: add missing __attribute__((format))Ævar Arnfjörð Bjarmason, Jul 13, 2021
  20. 4/6 *.h: add a few missing __attribute__((format))Ævar Arnfjörð Bjarmason, Jul 13, 2021
  21. 5/6 advice.h: add missing __attribute__((format)) & fix usageÆvar Arnfjörð Bjarmason, Jul 13, 2021
  22. 6/6 strbuf.h: add a comment about "missing" strftime() checkingÆvar Arnfjörð Bjarmason, Jul 13, 2021
  23. Jeff KingJul 13, 2021
  24. Jeff KingJul 13, 2021
  25. Junio C HamanoJul 13, 2021
  26. Ævar Arnfjörð BjarmasonJul 13, 2021
  27. 0/5 add missing __attribute__((format))Ævar Arnfjörð Bjarmason, Jul 14, 2021
  28. 1/5 *.c static functions: don't forward-declare __attribute__Ævar Arnfjörð Bjarmason, Jul 14, 2021
  29. 2/5 sequencer.c: move static function to avoid forward declÆvar Arnfjörð Bjarmason, Jul 14, 2021
  30. 3/5 *.c static functions: add missing __attribute__((format))Ævar Arnfjörð Bjarmason, Jul 14, 2021
  31. 5/5 advice.h: add missing __attribute__((format)) & fix usageÆvar Arnfjörð Bjarmason, Jul 14, 2021
  32. 4/5 *.h: add a few missing __attribute__((format))Ævar Arnfjörð Bjarmason, Jul 14, 2021
  33. Junio C HamanoJul 14, 2021

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.