From: Patrick Steinhardt Date: Wed, 04 Jun 2025 07:36:10 GMT Subject: Re: [PATCH 4/4] Fix unreachable-code warning with clang on Windows Message-ID: In-Reply-To: <20250603230646.2322671-4-mh@glandium.org> On Wed, Jun 04, 2025 at 08:06:46AM +0900, Mike Hommey wrote: > ``` > refs/files-backend.c:3187:5: error: code will never be executed [-Werror,-Wunreachable-code] > 3187 | continue; > | ^~~~~~~~ > 1 error generated. > ``` > > Signed-off-by: Mike Hommey > --- > refs/files-backend.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/refs/files-backend.c b/refs/files-backend.c > index bf6f89b1d1..af21eb80a9 100644 > --- a/refs/files-backend.c > +++ b/refs/files-backend.c > @@ -3183,7 +3183,7 @@ static int files_transaction_finish(struct ref_store *ref_store, > * next update. If not, we try and create a regular symref. > */ > if (update->new_target && refs->prefer_symlink_refs) > - if (!create_ref_symlink(lock, update->new_target)) > + if (NOT_CONSTANT(!create_ref_symlink(lock, update->new_target))) > continue; So the story here is that there are two implementations of `create_ref_symlink()`: - One macro that is defined to `(-1)` which is set when NO_SYMLINK_HEAD is defined. - A function that creates the ref symlink if NO_SYMLINK_HEAD is not defined. The function won't cause the error, but the macro will. So wouldn't it make more sense to wrap the macro itself in `NOT_CONSTANT`, like this: #define create_ref_symlink(a, b) NOT_CONSTANT(-1) Patrick