Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32.1k
gh-112970: Detect and use closefrom() on platforms where it is available#112969
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
47995c4
to179dd3c
Compareglibc-2.34 implements closefrom(3) using the same semantics as on BSD. Checkfor closefrom in configure and use the check result in fileutils.c rather thanhardcoding a FreeBSD check (which was wrong for other BSDs anyway).Signed-off-by: Sam James <sam@gentoo.org>
fe2d4ed
tobbb3254
CompareThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Thanks, this makes sense.
Uh oh!
There was an error while loading.Please reload this page.
Misc/NEWS.d/next/Library/2023-12-11-16-13-15.gh-issue-112970.87jmKP.rst OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
Signed-off-by: Sam James <sam@gentoo.org>
I noticed that
We should probably explicitly tell the compiler that we're throwing away the return value, to avoid possible future compiler warnings ( diff --git a/Python/fileutils.c b/Python/fileutils.cindex 9d12bc89c9..05cd70cdd0 100644--- a/Python/fileutils.c+++ b/Python/fileutils.c@@ -2922,7 +2922,7 @@ _Py_closerange(int first, int last) #ifdef USE_CLOSEFROM if (last >= sysconf(_SC_OPEN_MAX)) { /* Any errors encountered while closing file descriptors are ignored */- closefrom(first);+ (void)closefrom(first); } else #endif /* USE_CLOSEFROM */ |
There are two variants of closefrom, one returns void, but another returns int,so let's cast the return value to void to explicitly discard it to avoid -Wunused-resultwarnings.Signed-off-by: Sam James <sam@gentoo.org>
Ah, my bad for forgetting about that. I did a bunch of porting for packages getting this wrong a few years ago when glibc-2.34 came out, and forgot about it since. Done, thanks! |
Thanks; I'll land this tomorrow. |
Thanks for the report and patch,@thesamesam. Thanks for the additional review,@serhiy-storchaka. |
Thank you folks! |
…2969)glibc-2.34 implements closefrom(3) using the same semantics as on BSD.Check for closefrom() in configure and use the check result infileutils.c, rather than hardcoding a FreeBSD check.Some implementations of closefrom() return an int. Explicitly discard the return value by casting it to void, to avoid future compilerwarnings.Signed-off-by: Sam James <sam@gentoo.org>
…2969)glibc-2.34 implements closefrom(3) using the same semantics as on BSD.Check for closefrom() in configure and use the check result infileutils.c, rather than hardcoding a FreeBSD check.Some implementations of closefrom() return an int. Explicitly discard the return value by casting it to void, to avoid future compilerwarnings.Signed-off-by: Sam James <sam@gentoo.org>
Uh oh!
There was an error while loading.Please reload this page.
glibc-2.34 implements closefrom(3) using the same semantics as on BSD. Check for closefrom in configure and use the check result in fileutils.c rather than hardcoding a FreeBSD check (which was wrong for other BSDs anyway).