unix: fix pedantic compiler warnings

Fixes: https://github.com/libuv/libuv/issues/5051
This commit is contained in:
Ben Noordhuis 2026-03-10 21:45:30 +01:00
parent a19ceeb13a
commit 991c406624
2 changed files with 14 additions and 13 deletions

View File

@ -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);
}

View File

@ -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__ */