git: 01c0ddf44a77 - main - exterr: Fix build with GCC on 32-bit architectures

John Baldwin <[email protected]>
Newsgroups gmane.os.freebsd.devel.cvs.src
Message-ID <6a876750.319a2.6082c927__4904.13225941069$1787258746$gmane$org@gitrepo.freebsd.org>
The branch main has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=01c0ddf44a770a152a01259fd150fc77d5caac26

commit 01c0ddf44a770a152a01259fd150fc77d5caac26
Author:     John Baldwin <[email protected]>
AuthorDate: 2026-08-20 19:49:36 +0000
Commit:     John Baldwin <[email protected]>
CommitDate: 2026-08-20 19:49:36 +0000

    exterr: Fix build with GCC on 32-bit architectures
    
    Use an intermediate uintptr_t cast to avoid casting a uint64_t value
    directly to void * on 32-bit platforms (including lib32 builds).
    
    lib/libc/gen/uexterr_format.c: In function 'uexterr_format_msg':
    lib/libc/gen/uexterr_format.c:248:35: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
      248 |                         PFMT(fmt, (void *)ARG(nextarg));
          |                                   ^
    lib/libc/gen/uexterr_format.c:144:47: note: in definition of macro 'PFMT'
      144 |                 psz = snprintf(buf, bufsz, f, a);                       \
          |                                               ^
    
    Reported by:    GCC 15
    Fixes:          2f024a7cfddd ("exterr: relax format restrictions")
---
 lib/libc/gen/uexterr_format.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/libc/gen/uexterr_format.c b/lib/libc/gen/uexterr_format.c
index e32776c728bd..c983e71d0af1 100644
--- a/lib/libc/gen/uexterr_format.c
+++ b/lib/libc/gen/uexterr_format.c
@@ -245,7 +245,7 @@ uexterr_format_msg(const struct uexterror *ue, char *buf, size_t bufsz)
 			break;
 
 		case 'p':
-			PFMT(fmt, (void *)ARG(nextarg));
+			PFMT(fmt, (void *)(uintptr_t)ARG(nextarg));
 			break;
 
 		case '%':
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.