Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Merged

Conversation

thesamesam
Copy link
Contributor

@thesamesamthesamesam commentedDec 11, 2023
edited by bedevere-appbot
Loading

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).

@thesamesamthesamesam changed the titleWire up closefrom for Linuxgh-112970: Wire up closefrom for LinuxDec 11, 2023
glibc-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>
Copy link
Contributor

@erlend-aaslanderlend-aasland left a 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.

Signed-off-by: Sam James <sam@gentoo.org>
@erlend-aasland
Copy link
Contributor

I noticed thatclosefrom comes in two (or possibly more?) flavours:

  1. void closefrom(int)
  2. int closefrom(int)

We should probably explicitly tell the compiler that we're throwing away the return value, to avoid possible future compiler warnings (-Wunused-result):

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 */
thesamesam reacted with thumbs up emoji

@erlend-aaslanderlend-aasland changed the titlegh-112970: Wire up closefrom for Linuxgh-112970: Detect and use closefrom() on platforms where it is availableDec 11, 2023
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>
@thesamesam
Copy link
ContributorAuthor

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!

erlend-aasland reacted with hooray emoji

@erlend-aasland
Copy link
Contributor

Thanks; I'll land this tomorrow.

thesamesam reacted with rocket emoji

@erlend-aaslanderlend-aasland merged commitc454e93 intopython:mainDec 12, 2023
@erlend-aasland
Copy link
Contributor

Thanks for the report and patch,@thesamesam. Thanks for the additional review,@serhiy-storchaka.

thesamesam reacted with thumbs up emoji

@thesamesamthesamesam deleted the wire-up-closefrom-linux branchDecember 12, 2023 14:09
@thesamesam
Copy link
ContributorAuthor

Thank you folks!

erlend-aasland reacted with heart emoji

aisk pushed a commit to aisk/cpython that referenced this pull requestFeb 11, 2024
…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>
Glyphack pushed a commit to Glyphack/cpython that referenced this pull requestSep 2, 2024
…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>
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@serhiy-storchakaserhiy-storchakaserhiy-storchaka approved these changes

@erlend-aaslanderlend-aaslanderlend-aasland approved these changes

@corona10corona10Awaiting requested review from corona10corona10 is a code owner

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@thesamesam@erlend-aasland@serhiy-storchaka

[8]ページ先頭

©2009-2025 Movatter.jp