Re: [PATCH] refs: forbid clang to complain about unreachable code
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Oct 10, 2025, 13:49 UTC
- Message-ID
- <2346bcc7-b60e-0ad6-14fe-c0b49e427921@gmx.de>
- In-Reply-To
- <aOia55_sjFQjw1UQ@pks.im>
Hi Patrick,
On Fri, 10 Oct 2025, Patrick Steinhardt wrote:
Show 13 quoted lines
> diff --git a/refs/files-backend.c b/refs/files-backend.c
> index bb2bec3807..cb402a2a54 100644
> --- a/refs/files-backend.c
> +++ b/refs/files-backend.c
> @@ -2115,7 +2115,7 @@ static int commit_ref_update(struct files_ref_store *refs,
> }
>
> #ifdef NO_SYMLINK_HEAD
> -#define create_ref_symlink(a, b) (-1)
> +#define create_ref_symlink(a, b) NOT_CONSTANT(-1)
> #else
> static int create_ref_symlink(struct ref_lock *lock, const char *target)
> {While this is correct, and "closer to the root", in my experience it is better to have work-arounds closer to where the symptom appears. In this case, it would be directly in the condition of the `if ()` construct. Therefore, I would prefer to keep the proposed patch as-is.
Ciao, Johannes