Re: [PATCH 4/4] Fix unreachable-code warning with clang on Windows

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxx>
> ---
>  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




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux