From 991c406624f47c0efb343cd0b74788ceff63510e Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Tue, 10 Mar 2026 21:45:30 +0100 Subject: [PATCH] unix: fix pedantic compiler warnings Fixes: https://github.com/libuv/libuv/issues/5051 --- src/unix/fs.c | 25 +++++++++++++------------ src/uv-common.c | 2 +- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/unix/fs.c b/src/unix/fs.c index fc0fe0a26..a45c95a17 100644 --- a/src/unix/fs.c +++ b/src/unix/fs.c @@ -460,27 +460,28 @@ static ssize_t uv__preadv_or_pwritev(int fd, off_t off, _Atomic uintptr_t* cache, int is_pread) { - ssize_t (*f)(int, const struct iovec*, uv__iovcnt, off_t); - void* p; + union { + ssize_t (*f)(int, const struct iovec*, uv__iovcnt, off_t); + void* p; + } u; - p = (void*) atomic_load_explicit(cache, memory_order_relaxed); - if (p == NULL) { + u.p = (void*) atomic_load_explicit(cache, memory_order_relaxed); + if (u.p == NULL) { #ifdef RTLD_DEFAULT /* Try _LARGEFILE_SOURCE version of preadv/pwritev first, * then fall back to the plain version, for libcs like musl. */ - p = dlsym(RTLD_DEFAULT, is_pread ? "preadv64" : "pwritev64"); - if (p == NULL) - p = dlsym(RTLD_DEFAULT, is_pread ? "preadv" : "pwritev"); + u.p = dlsym(RTLD_DEFAULT, is_pread ? "preadv64" : "pwritev64"); + if (u.p == NULL) + u.p = dlsym(RTLD_DEFAULT, is_pread ? "preadv" : "pwritev"); dlerror(); /* Clear errors. */ #endif /* RTLD_DEFAULT */ - if (p == NULL) - p = is_pread ? uv__preadv_emul : uv__pwritev_emul; - atomic_store_explicit(cache, (uintptr_t) p, memory_order_relaxed); + if (u.p == NULL) + u.f = is_pread ? uv__preadv_emul : uv__pwritev_emul; + atomic_store_explicit(cache, (uintptr_t) u.p, memory_order_relaxed); } - f = p; - return f(fd, bufs, nbufs, off); + return u.f(fd, bufs, nbufs, off); } diff --git a/src/uv-common.c b/src/uv-common.c index e5a763290..f1e8928d3 100644 --- a/src/uv-common.c +++ b/src/uv-common.c @@ -957,7 +957,7 @@ void uv_free_cpu_info(uv_cpu_info_t* cpu_infos, int count) { int i; for (i = 0; i < count; i++) - uv__free(cpu_infos[i].model); + uv__free((char*) cpu_infos[i].model); uv__free(cpu_infos); #endif /* __linux__ */