All of lore.kernel.org
 help / color / mirror / Atom feed
From: Patrick Steinhardt <ps@pks.im>
To: Mike Hommey <mh@glandium.org>
Cc: git@vger.kernel.org, gitster@pobox.com
Subject: Re: [PATCH 4/4] Fix unreachable-code warning with clang on Windows
Date: Wed, 4 Jun 2025 09:36:10 +0200	[thread overview]
Message-ID: <aD_3ahX2jyrtfvjq@pks.im> (raw)
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 <mh@glandium.org>
> ---
>  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

  reply	other threads:[~2025-06-04  7:36 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-03 23:06 [PATCH 1/4] Fix maybe-uninitialized warning with GCC at -O3 Mike Hommey
2025-06-03 23:06 ` [PATCH 2/4] Fix use-after-free " Mike Hommey
2025-06-03 23:47   ` Junio C Hamano
2025-06-04  7:36   ` Patrick Steinhardt
2025-06-03 23:06 ` [PATCH 3/4] Fix comma warnings with clang on Windows Mike Hommey
2025-06-03 23:51   ` Junio C Hamano
2025-06-03 23:06 ` [PATCH 4/4] Fix unreachable-code warning " Mike Hommey
2025-06-04  7:36   ` Patrick Steinhardt [this message]
2025-06-04 15:50     ` Junio C Hamano
2025-06-04  7:36 ` [PATCH 1/4] Fix maybe-uninitialized warning with GCC at -O3 Patrick Steinhardt
2025-06-06  0:23   ` Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aD_3ahX2jyrtfvjq@pks.im \
    --to=ps@pks.im \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=mh@glandium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.