From 6b4cecafa34f3aa91ff49697fb8bb21d3c3c525e Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Wed, 21 Oct 2026 18:19:30 +0000 Subject: [PATCH 1/3] gh-160359: Accept older musl `getdents64` buffer declarations --- Modules/_posixsubprocess.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/_posixsubprocess.c b/Modules/_posixsubprocess.c index 2291280ec117f2c..420a4769db184cf 100644 --- a/Modules/_posixsubprocess.c +++ b/Modules/_posixsubprocess.c @@ -436,7 +436,7 @@ _close_open_fds_safe(int start_fd, int *fds_to_keep, Py_ssize_t fds_to_keep_len) Py_ssize_t bytes; while (1) { #ifdef HAVE_GETDENTS64 - bytes = getdents64(fd_dir_fd, buffer, sizeof(buffer)); + bytes = getdents64(fd_dir_fd, (void *)buffer, sizeof(buffer)); #else bytes = syscall(SYS_getdents64, fd_dir_fd, (struct py_dirent64 *)buffer, sizeof(buffer)); From dfbc0e9b09b32c615ca98a429cd4e3ea07e347c7 Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Thu, 22 Oct 2026 16:57:22 -0700 Subject: [PATCH 2/3] Apply suggestion from @zanieb --- Modules/_posixsubprocess.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Modules/_posixsubprocess.c b/Modules/_posixsubprocess.c index 420a4769db184cf..c46df9556dce022 100644 --- a/Modules/_posixsubprocess.c +++ b/Modules/_posixsubprocess.c @@ -436,6 +436,9 @@ _close_open_fds_safe(int start_fd, int *fds_to_keep, Py_ssize_t fds_to_keep_len) Py_ssize_t bytes; while (1) { #ifdef HAVE_GETDENTS64 + # musl <1.2.4 headers expose `getdents64` as an alias for `getdents`, whose buffer parameter + # is `struct dirent *`. We use `void *` to support both that interface and the glibc declaration + # without an incompatible-pointer diagnostic. bytes = getdents64(fd_dir_fd, (void *)buffer, sizeof(buffer)); #else bytes = syscall(SYS_getdents64, fd_dir_fd, From 8ecea48e114e9b6769b5fd19c0d8d81570cff513 Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Thu, 22 Oct 2026 16:58:36 -0700 Subject: [PATCH 3/3] Apply suggestion from @zanieb --- Modules/_posixsubprocess.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Modules/_posixsubprocess.c b/Modules/_posixsubprocess.c index c46df9556dce022..415e0afbe88125e 100644 --- a/Modules/_posixsubprocess.c +++ b/Modules/_posixsubprocess.c @@ -436,9 +436,10 @@ _close_open_fds_safe(int start_fd, int *fds_to_keep, Py_ssize_t fds_to_keep_len) Py_ssize_t bytes; while (1) { #ifdef HAVE_GETDENTS64 - # musl <1.2.4 headers expose `getdents64` as an alias for `getdents`, whose buffer parameter - # is `struct dirent *`. We use `void *` to support both that interface and the glibc declaration - # without an incompatible-pointer diagnostic. + /* musl <1.2.4 headers expose `getdents64` as an alias for `getdents`, whose buffer parameter + * is `struct dirent *`. We use `void *` to support both that interface and the glibc declaration + * without an incompatible-pointer diagnostic. + */ bytes = getdents64(fd_dir_fd, (void *)buffer, sizeof(buffer)); #else bytes = syscall(SYS_getdents64, fd_dir_fd,