Re: git: d316de24faa7 - main - zfs: Avoid a gcc -Wint-to-pointer-cast warning

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Fri, 17 May 2024 16:16:52 UTC
On 5/17/24 9:01 AM, Brooks Davis wrote:
> The branch main has been updated by brooks:
> 
> URL: https://cgit.FreeBSD.org/src/commit/?id=d316de24faa7453118a90fb0e9839e8026e36a4e
> 
> commit d316de24faa7453118a90fb0e9839e8026e36a4e
> Author:     Brooks Davis <brooks@FreeBSD.org>
> AuthorDate: 2024-05-17 15:59:06 +0000
> Commit:     Brooks Davis <brooks@FreeBSD.org>
> CommitDate: 2024-05-17 16:01:19 +0000
> 
>      zfs: Avoid a gcc -Wint-to-pointer-cast warning
>      
>      On 32-bit platforms long long is generally 64-bits.  Sufficiently modern
>      versions of gcc (13 in my testing) complains when casting a pointer to
>      an integer of a different width so cast to uintptr_t first to avoid the
>      warning.
>      
>      Fix i386 gcc builds while we wait for this to be merged to OpenZFS.
>      
>      Sponsored by:   DARPA, AFRL
>      Pull Request:   https://github.com/openzfs/zfs/pull/16203
> ---
>   sys/contrib/openzfs/module/zfs/spa.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/sys/contrib/openzfs/module/zfs/spa.c b/sys/contrib/openzfs/module/zfs/spa.c
> index ec2b674fb7ee..c3800e018c73 100644
> --- a/sys/contrib/openzfs/module/zfs/spa.c
> +++ b/sys/contrib/openzfs/module/zfs/spa.c
> @@ -6832,7 +6832,7 @@ spa_tryimport(nvlist_t *tryconfig)
>   	 */
>   	char *name = kmem_alloc(MAXPATHLEN, KM_SLEEP);
>   	(void) snprintf(name, MAXPATHLEN, "%s-%llx-%s",
> -	    TRYIMPORT_NAME, (u_longlong_t)curthread, poolname);
> +	    TRYIMPORT_NAME, (u_longlong_t)(uintptr_t)curthread, poolname);
>   
>   	mutex_enter(&spa_namespace_lock);
>   	spa = spa_add(name, tryconfig, NULL);

Huh, this shouldn't be broken anymore.  The kernel module has an unconditional
CFLAGS to disable -Wint-to-pointer-cast, and I just added it to the userspace
build back in 766c4ad385ccf96f8cf10129363a6bfa58b3e92f.  OTOH, it might be
nice to re-enable the warning if it is clean for both kernel and userland.

-- 
John Baldwin