[PATCH 1/2] git-compat-util.h: clarify comment on GCC-specific code
- From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
- Date
- Apr 12, 2021, 11:02 UTC
- Message-ID
- <patch-1.2-a8cc05cf56f-20210412T105422Z-avarab@gmail.com>
- In-Reply-To
- <cover-0.2-00000000000-20210412T105422Z-avarab@gmail.com>
Change a comment added in e208f9cc757 (make error()'s constant return value more visible, 2012-12-15) to note that the code doesn't only depend on variadic macros, which have been a hard dependency since 765dc168882 (git-compat-util: always enable variadic macros, 2021-01-28), but also on GCC's handling of __VA_ARGS__. The commit message for e208f9cc757 made this clear, but the comment it added did not.
See also e05bed960d3 (trace: add 'file:line' to all trace output, 2014-07-12) for another comment about GNUC's handling of __VA_ARGS__.
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> --- git-compat-util.h | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/git-compat-util.h b/git-compat-util.h index 9ddf9d7044b..540aba22a4d 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -480,10 +480,15 @@ void warning_errno(const char *err, ...) __attribute__((format (printf, 1, 2))); /* * Let callers be aware of the constant return value; this can help - * gcc with -Wuninitialized analysis. We restrict this trick to gcc, though, - * because some compilers may not support variadic macros. Since we're only - * trying to help gcc, anyway, it's OK; other compilers will fall back to - * using the function as usual. + * gcc with -Wuninitialized analysis. + * + * We restrict this trick to gcc, though, because while we rely on the + * presence of C99 variadic macros, this code also relies on the + * non-standard behavior of GCC's __VA_ARGS__, allowing error() to + * work even if no format specifiers are passed to error(). + * + * Since we're only trying to help gcc, anyway, it's OK; other + * compilers will fall back to using the function as usual. */ #if defined(__GNUC__) static inline int const_error(void)
-- 2.31.1.631.gb80e078001e