Skip to content

RFC Compile cleanly in pedantic mode

Beat Bolli git 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest6 patches 18 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/6connect.h: avoid forward declaration of an enumconnect.h+2 -00 replies
1/6connect.h: avoid forward declaration of an enumconnect.h+2 -00 replies
2/6refs/refs-internal.h: avoid forward declaration of an enumrefs/refs-internal.h+2 -03 replies
2/6refs/refs-internal.h: avoid forward declaration of an enumrefs/refs-internal.h+2 -00 replies
3/6convert.c: replace "\e" escapes with "\033".convert.c+1 -10 replies
3/6convert.c: replace "\e" escapes with "\033".convert.c+1 -10 replies
4/6sequencer.c: avoid empty statements at top levelsequencer.c+2 -25 replies
4/6sequencer.c: avoid empty statements at top levelpath.h sequencer.c+3 -31 reply
5/6string-list.c: avoid conversion from void * to function pointerstring-list.c+14 -40 replies
5/6string-list.c: avoid conversion from void * to function pointerstring-list.c+14 -40 replies
6/6utf8.c: avoid char overflowutf8.c+5 -57 replies
6/6utf8.c: avoid char overflowutf8.c+4 -40 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [RFC PATCH 0/6] Compile cleanly in pedantic mode

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/