std: map ENOTSUP to ErrorKind::Unsupported - #158580
Conversation
|
No reasoning was given in the PR where the behavior was changed. It was simply claimed to be incorrect. |
|
As far as I understand it, |
|
https://lists.gnu.org/archive/html/bug-glibc/2002-08/msg00017.html So |
You're right that I didn't justify in PR the mapping beyond calling the old one incorrect, so I won't lean on it as precedent.
The reason I'd keep the two together is simpler: ENOTSUP and EOPNOTSUPP are the same integer on Linux, Android and FreeBSD, so an ENOTSUP error already decodes to Unsupported there through the existing arm.
You're right that neither strictly means "never succeeds on this platform" (both can be per-socket or per-fs), so I'm happy to take the broader question to a separate issue if you'd rather reconsider Unsupported for both, reverting #139822 included. The goal is portability: an ENOTSUP fallback that matches ErrorKind::Unsupported shouldn't work on Linux but silently miss on macOS. Left as-is, ENOTSUP just stays inconsistent with EOPNOTSUPP on the targets where they differ. |
...Typo? That was by @ozgureyilmaz, so surely it was not your responsibility to justify the PR that you did not author. But yes, I think we can agree that whatever is decided, the reasoning should be able to stand on its own. And I can see the argument for making the change. At the very least, surely we should be offering something better than just "Uncategorized". |
|
I don't particularly understand the implications of this change. r? @workingjubilee; feel free to reassign if wanted |
|
|
|
honestly I'm not sure if anyone does :ferris_clueless: |
|
Okay, so currently Unsupported doc itself says "the operation can never succeed", but that already isn't true for what maps there.
EOPNOTSUPP already in Unsupported is per socket and ENOTSUP is per-fd/fs, both can suceed on a different object. Not pushing any of these, just mapping what I see:
I feel like option 1, is a minimal change that fixes the inconsistency, and avoid potential confusion. |
This comment has been minimized.
This comment has been minimized.
decode_error_kind maps EOPNOTSUPP to Unsupported but not ENOTSUP. The two are the same value on some targets (Linux, FreeBSD), where that arm already covers both, and different on others (Apple, OpenBSD), where ENOTSUP fell through to Uncategorized. Since they alias on some targets, an or-pattern would be an unreachable arm there; use a match guard, like the existing EAGAIN/EWOULDBLOCK arm.
9a9e690 to
bc4ab23
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
Rebased onto master. |
|
@rfcbot merge libs-api |
|
@joshtriplett has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
|
Per today's libs-api meeting, we're happy with this; since it's a commitment to use that error kind, this will need FCP though. |
|
🔔 This is now entering its final comment period, as per the review above. 🔔 |
|
The final comment period, with a disposition to merge, as per the review above, is now complete. As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed. |
| // EOPNOTSUPP and ENOTSUP can have the same value on some systems, | ||
| // but different values on others (e.g. Apple), so we can't use a | ||
| // match clause | ||
| x if x == libc::EOPNOTSUPP || x == libc::ENOTSUP => Unsupported, |
There was a problem hiding this comment.
Note that there is also ENOSYS mapping to the same thing. Seems better to group all 3 together.
There was a problem hiding this comment.
Thanks for highlighting this, you are right ENOSYS maps to Unsupported as well.
Currently the guard was added because Linux libc defines ENOTSUP as EOPNOTSUPP (same value), so an or-pattern would be unreachable and dead code on Linux (95 | 95 => ...).
ENOSYS have distinct value, so it doesn't need a guard, and keeping it as pattern has some benefits (compiler could catch if it will collide with another arm).
I could add it, if you prefer to have 3 of them grouped together anyway, if not, i could just move ENOSYS arm right above this guard, so Unsupported case will be near each other.
There was a problem hiding this comment.
IMO it'd be best to have them all next to each other -- whether as one arm or as two (one using the if ... || ...) doesn't matter much IMO.
There was a problem hiding this comment.
Yeah agree, moved ENOSYS to have Unsupported cases next to each other.
View all comments
ENOTSUPandEOPNOTSUPPboth mean the operation isn't supported. They're the same value on some targets (Linux, FreeBSD), where the existingEOPNOTSUPP => Unsupportedarm (#139822) already covers both, and different on others (Apple, OpenBSD), whereENOTSUPdecodes toUncategorizedinstead. I don't see a reason to treat it differently, so this mapsENOTSUPtoUnsupportedas well.It uses a match guard rather than an or-pattern, since the two are equal on the targets where they alias and an or-pattern would be unreachable there. Same shape as the
EAGAIN/EWOULDBLOCKarm just below:This was raised once before (#125228) and closed, since both errnos were left out of the original
UnsupportedPR (#78880). #139822 has since addedEOPNOTSUPP, so the same reasoning now coversENOTSUP.I didn't add a test, since the decode arms aren't tested today.
r? libs