]> git.ipfire.org Git - thirdparty/git.git/commit
refs: forbid clang to complain about unreachable code
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Thu, 9 Oct 2025 07:46:22 +0000 (07:46 +0000)
committerJunio C Hamano <gitster@pobox.com>
Thu, 9 Oct 2025 20:22:09 +0000 (13:22 -0700)
commit3860985105a40f425effc49642693e90e84e1863
tree2e52814545d0869dbac4b498a8af82e61f037f90
parentc44beea485f0f2feaf460e2ac87fdd5608d63cf0
refs: forbid clang to complain about unreachable code

When `NO_SYMLINK_HEAD` is defined, `create_ref_symlink()` is hard-coded
as `(-1)`, and as a consequence the condition `!create_ref_symlink()`
always evaluates to false, rendering any code guarded by that condition
unreachable.

Therefore, clang is _technically_ correct when it complains about
unreachable code. It does completely miss the fact that this is okay
because on _other_ platforms, where `NO_SYMLINK_HEAD` is not defined,
the code isn't unreachable at all.

Let's use the same trick as in 82e79c63642c (git-compat-util: add
NOT_CONSTANT macro and use it in atfork_prepare(), 2025-03-17) to
appease clang while at the same time keeping the `-Wunreachable` flag
to potentially find _actually_ unreachable code.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
refs/files-backend.c