std: map ENOTSUP to ErrorKind::Unsupported#158580
Conversation
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.
|
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. |
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