While developing 6aaded550 ("builtin/config: work around an unsized
array forward declaration", 2018-07-05), I have compiled Git with
CFLAGS="-std=c99 -pedantic".
This is an RFC patch series that fixes a few compiler warnings when
compiling with these options, always assuming that this is a worthwile
goal.
Note that all warnings were produced by -pedantic; the C99 standard
option by itself didn't cause any of them.
The warnings were:
1) Char arrays initialized from a parenthesized string.
Suppressed by defining USE_PARENS_AROUND_GETTEXT_N to 0
globally. This was done just to keep the amount of warnings
manageable; this series leaves that knob alone. The advantage of
not mistakenly concatenating two translated strings is greater.
2) connect.h, refs/refs-internal.h: Forward reference to an enum.
Added two #includes that define the enums. This was already
(inconclusively) talked about in [0].
3) convert.c: Invalid escape sequence "\e".
Replaced with "\033".
4) seqencer.c: Empty statements at top level.
Removed the extra semicolons.
5) string-list.c: Forbidden to cast from void * to a function pointer and
vice versa.
Encapsulated the function pointer in a context struct. This is
controversial because it has a performance impact, namely one
additional pointer dereference per string comparison. An
alternative might be to use multiple casts via intptr_t. But
I'm not sure if this is worth the trouble.
6) utf8.c: overflow of char values.
Use unsigned char for the BOM constants.
This series has patches for 2) to 6).
Regards,
Beat
[0]
https://public-inbox.org/git/[email protected]/T/