Skip to content

Commit af2ee71

Browse files
authored
Merge pull request #1452 from asomers/errno-values
Fix several problems with Errno aliases
2 parents 4c15c53 + 6f15bf3 commit af2ee71

File tree

2 files changed

+44
-33
lines changed

2 files changed

+44
-33
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,17 @@ This project adheres to [Semantic Versioning](https://semver.org/).
4040
(#[1440](https://github.com/nix-rust/nix/pull/1440))
4141
- Minimum supported Rust version is now 1.41.0.
4242
([#1440](https://github.com/nix-rust/nix/pull/1440))
43+
- Errno aliases are now associated consts on `Errno`, instead of consts in the
44+
`errno` module.`
45+
(#[1452](https://github.com/nix-rust/nix/pull/1452))
4346

4447
### Fixed
4548
- Allow `sockaddr_ll` size, as reported by the Linux kernel, to be smaller then it's definition
4649
(#[1395](https://github.com/nix-rust/nix/pull/1395))
4750
- Fix spurious errors using `sendmmsg` with multiple cmsgs
4851
(#[1414](https://github.com/nix-rust/nix/pull/1414))
52+
- Added `Errno::EOPNOTSUPP` to FreeBSD, where it was missing.
53+
(#[1452](https://github.com/nix-rust/nix/pull/1452))
4954

5055
### Removed
5156

@@ -57,6 +62,8 @@ This project adheres to [Semantic Versioning](https://semver.org/).
5762
longer be needed now that async/await are available. `AioCb`s now work
5863
exclusively with borrowed buffers, not owned ones.
5964
(#[1440](https://github.com/nix-rust/nix/pull/1440))
65+
- Removed some Errno values from platforms where they aren't actually defined.
66+
(#[1452](https://github.com/nix-rust/nix/pull/1452))
6067

6168
## [0.20.0] - 20 February 2021
6269
### Added

src/errno.rs

Lines changed: 37 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -843,9 +843,11 @@ mod consts {
843843
EHWPOISON = libc::EHWPOISON,
844844
}
845845

846-
pub const EWOULDBLOCK: Errno = Errno::EAGAIN;
847-
pub const EDEADLOCK: Errno = Errno::EDEADLK;
848-
pub const ENOTSUP: Errno = Errno::EOPNOTSUPP;
846+
impl Errno {
847+
pub const EWOULDBLOCK: Errno = Errno::EAGAIN;
848+
pub const EDEADLOCK: Errno = Errno::EDEADLK;
849+
pub const ENOTSUP: Errno = Errno::EOPNOTSUPP;
850+
}
849851

850852
pub fn from_i32(e: i32) -> Errno {
851853
use self::Errno::*;
@@ -1103,11 +1105,11 @@ mod consts {
11031105
EQFULL = libc::EQFULL,
11041106
}
11051107

1106-
pub const ELAST: Errno = Errno::EQFULL;
1107-
pub const EWOULDBLOCK: Errno = Errno::EAGAIN;
1108-
pub const EDEADLOCK: Errno = Errno::EDEADLK;
1109-
1110-
pub const EL2NSYNC: Errno = Errno::UnknownErrno;
1108+
impl Errno {
1109+
pub const ELAST: Errno = Errno::EQFULL;
1110+
pub const EWOULDBLOCK: Errno = Errno::EAGAIN;
1111+
pub const EDEADLOCK: Errno = Errno::EDEADLK;
1112+
}
11111113

11121114
pub fn from_i32(e: i32) -> Errno {
11131115
use self::Errno::*;
@@ -1328,11 +1330,12 @@ mod consts {
13281330
EOWNERDEAD = libc::EOWNERDEAD,
13291331
}
13301332

1331-
pub const ELAST: Errno = Errno::EOWNERDEAD;
1332-
pub const EWOULDBLOCK: Errno = Errno::EAGAIN;
1333-
pub const EDEADLOCK: Errno = Errno::EDEADLK;
1334-
1335-
pub const EL2NSYNC: Errno = Errno::UnknownErrno;
1333+
impl Errno {
1334+
pub const ELAST: Errno = Errno::EOWNERDEAD;
1335+
pub const EWOULDBLOCK: Errno = Errno::EAGAIN;
1336+
pub const EDEADLOCK: Errno = Errno::EDEADLK;
1337+
pub const EOPNOTSUPP: Errno = Errno::ENOTSUP;
1338+
}
13361339

13371340
pub fn from_i32(e: i32) -> Errno {
13381341
use self::Errno::*;
@@ -1542,12 +1545,12 @@ mod consts {
15421545
EASYNC = libc::EASYNC,
15431546
}
15441547

1545-
pub const ELAST: Errno = Errno::EASYNC;
1546-
pub const EWOULDBLOCK: Errno = Errno::EAGAIN;
1547-
pub const EDEADLOCK: Errno = Errno::EDEADLK;
1548-
pub const EOPNOTSUPP: Errno = Errno::ENOTSUP;
1549-
1550-
pub const EL2NSYNC: Errno = Errno::UnknownErrno;
1548+
impl Errno {
1549+
pub const ELAST: Errno = Errno::EASYNC;
1550+
pub const EWOULDBLOCK: Errno = Errno::EAGAIN;
1551+
pub const EDEADLOCK: Errno = Errno::EDEADLK;
1552+
pub const EOPNOTSUPP: Errno = Errno::ENOTSUP;
1553+
}
15511554

15521555
pub fn from_i32(e: i32) -> Errno {
15531556
use self::Errno::*;
@@ -1756,10 +1759,10 @@ mod consts {
17561759
EPROTO = libc::EPROTO,
17571760
}
17581761

1759-
pub const ELAST: Errno = Errno::ENOTSUP;
1760-
pub const EWOULDBLOCK: Errno = Errno::EAGAIN;
1761-
1762-
pub const EL2NSYNC: Errno = Errno::UnknownErrno;
1762+
impl Errno {
1763+
pub const ELAST: Errno = Errno::ENOTSUP;
1764+
pub const EWOULDBLOCK: Errno = Errno::EAGAIN;
1765+
}
17631766

17641767
pub fn from_i32(e: i32) -> Errno {
17651768
use self::Errno::*;
@@ -1969,10 +1972,10 @@ mod consts {
19691972
EPROTO = libc::EPROTO,
19701973
}
19711974

1972-
pub const ELAST: Errno = Errno::ENOTSUP;
1973-
pub const EWOULDBLOCK: Errno = Errno::EAGAIN;
1974-
1975-
pub const EL2NSYNC: Errno = Errno::UnknownErrno;
1975+
impl Errno {
1976+
pub const ELAST: Errno = Errno::ENOTSUP;
1977+
pub const EWOULDBLOCK: Errno = Errno::EAGAIN;
1978+
}
19761979

19771980
pub fn from_i32(e: i32) -> Errno {
19781981
use self::Errno::*;
@@ -2172,10 +2175,9 @@ mod consts {
21722175
EPROTO = libc::EPROTO,
21732176
}
21742177

2175-
pub const ELAST: Errno = Errno::UnknownErrno;
2176-
pub const EWOULDBLOCK: Errno = Errno::EAGAIN;
2177-
2178-
pub const EL2NSYNC: Errno = Errno::UnknownErrno;
2178+
impl Errno {
2179+
pub const EWOULDBLOCK: Errno = Errno::EAGAIN;
2180+
}
21792181

21802182
pub fn from_i32(e: i32) -> Errno {
21812183
use self::Errno::*;
@@ -2400,8 +2402,10 @@ mod consts {
24002402
ESTALE = libc::ESTALE,
24012403
}
24022404

2403-
pub const ELAST: Errno = Errno::ESTALE;
2404-
pub const EWOULDBLOCK: Errno = Errno::EAGAIN;
2405+
impl Errno {
2406+
pub const ELAST: Errno = Errno::ESTALE;
2407+
pub const EWOULDBLOCK: Errno = Errno::EAGAIN;
2408+
}
24052409

24062410
pub fn from_i32(e: i32) -> Errno {
24072411
use self::Errno::*;

0 commit comments

Comments
 (0)