Skip to content

Commit 57fa56f

Browse files
committed
Make sure to leave the values as-is in open
1 parent 4c28b9f commit 57fa56f

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/fcntl.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,7 @@ libc_bitflags!(
163163

164164
pub fn open<P: ?Sized + NixPath>(path: &P, oflag: OFlag, mode: Mode) -> Result<RawFd> {
165165
let fd = path.with_nix_path(|cstr| {
166-
let modebits = c_uint::from(mode.bits());
167-
unsafe { libc::open(cstr.as_ptr(), oflag.bits(), modebits) }
166+
unsafe { libc::open(cstr.as_ptr(), oflag.bits(), mode.bits() as c_uint) }
168167
})?;
169168

170169
Errno::result(fd)
@@ -178,8 +177,7 @@ pub fn openat<P: ?Sized + NixPath>(
178177
mode: Mode,
179178
) -> Result<RawFd> {
180179
let fd = path.with_nix_path(|cstr| {
181-
let modebits = c_uint::from(mode.bits());
182-
unsafe { libc::openat(dirfd, cstr.as_ptr(), oflag.bits(), modebits) }
180+
unsafe { libc::openat(dirfd, cstr.as_ptr(), oflag.bits(), mode.bits() as c_uint) }
183181
})?;
184182
Errno::result(fd)
185183
}

0 commit comments

Comments
 (0)