[PATCH v3 0/3] -Wunreachable-code
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Mar 17, 2025, 23:53 UTC
- Message-ID
- <20250317235329.809302-1-gitster@pobox.com>
- In-Reply-To
- <20250314210909.3776678-1-gitster@pobox.com>
As Taylor noticed, we can still help macOS users by first dealing with the false positive in the code, and then flip the warning option for developers on.
[1/3] run-command: use errno to check for sigfillset() error
This was our first "workaround" that is very specific to the code that gets falsely flagged by the compiler.
[2/3] git-compat-util: add NOT_CONSTANT macro and use it in atfork_prepare()
This adds a more generic way to work around a false positive from -Wunreachable-code to prevent compilers from optimize away expressions that are used in conditionals, and rewrite the earlier workaround with it.
[3/3] config.mak.dev: enable -Wunreachable-code
Now we worked around known false positive of -Wunreachable-code, we force it upon our developers, including macOS ones.
This is totally offtopic, but I often find the short-log (list of commits, grouped by author) in the cover letter very awkward to work with. Between v2 and v3, aside from the NOT_CONSTANT() improvements in the patch [2/3] that used to be [3/3], one large change is the reordering of the patches but that is not seen in the shortlog (I ran "git log --oneline -reverse" to prepare the list of commits in the order they are applied to describe them in the above list).
Jeff King (2): run-command: use errno to check for sigfillset() error config.mak.dev: enable -Wunreachable-code
Junio C Hamano (1): git-compat-util: add NOT_CONSTANT macro and use it in atfork_prepare()
Makefile | 1 + compiler-tricks/not-a-constant.c | 2 ++ config.mak.dev | 1 + git-compat-util.h | 9 +++++++++ meson.build | 2 ++ run-command.c | 8 +++++++- 6 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 compiler-tricks/not-a-constant.c
-- 2.49.0-207-gc8924421c3