Skip to content

Commit 1d5c730

Browse files
authored
Merge pull request #2117 from asomers/revert-bitflags
Revert "Merge #2027 #2057"
2 parents 8a2325a + 12699b7 commit 1d5c730

File tree

11 files changed

+15
-17
lines changed

11 files changed

+15
-17
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ targets = [
2828

2929
[dependencies]
3030
libc = { version = "0.2.137", features = [ "extra_traits" ] }
31-
bitflags = "2.3.1"
31+
bitflags = "1.1"
3232
cfg-if = "1.0"
3333
pin-utils = { version = "0.1.0", optional = true }
3434

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
#![warn(missing_docs)]
5555
#![cfg_attr(docsrs, feature(doc_cfg))]
5656
#![deny(clippy::cast_ptr_alignment)]
57+
#![allow(clippy::bad_bit_mask)]
5758

5859
// Re-exported external crates
5960
pub use libc;

src/macros.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ macro_rules! libc_bitflags {
6363
}
6464
) => {
6565
::bitflags::bitflags! {
66-
#[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
67-
#[repr(transparent)]
6866
$(#[$outer])*
6967
pub struct $BitFlags: $T {
7068
$(

src/mount/bsd.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ impl<'a> Nmount<'a> {
392392

393393
let niov = self.iov.len() as c_uint;
394394
let iovp = self.iov.as_mut_ptr();
395-
let res = unsafe { libc::nmount(iovp, niov, flags.bits()) };
395+
let res = unsafe { libc::nmount(iovp, niov, flags.bits) };
396396
match Errno::result(res) {
397397
Ok(_) => Ok(()),
398398
Err(error) => {
@@ -446,7 +446,7 @@ where
446446
P: ?Sized + NixPath,
447447
{
448448
let res = mountpoint.with_nix_path(|cstr| unsafe {
449-
libc::unmount(cstr.as_ptr(), flags.bits())
449+
libc::unmount(cstr.as_ptr(), flags.bits)
450450
})?;
451451

452452
Errno::result(res).map(drop)

src/mount/linux.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ pub fn mount<
8888
s,
8989
t.as_ptr(),
9090
ty,
91-
flags.bits(),
91+
flags.bits,
9292
d as *const libc::c_void,
9393
)
9494
})
@@ -108,7 +108,7 @@ pub fn umount<P: ?Sized + NixPath>(target: &P) -> Result<()> {
108108

109109
pub fn umount2<P: ?Sized + NixPath>(target: &P, flags: MntFlags) -> Result<()> {
110110
let res = target.with_nix_path(|cstr| unsafe {
111-
libc::umount2(cstr.as_ptr(), flags.bits())
111+
libc::umount2(cstr.as_ptr(), flags.bits)
112112
})?;
113113

114114
Errno::result(res).map(drop)

src/mqueue.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ impl MqAttr {
139139
/// Open a message queue
140140
///
141141
/// See also [`mq_open(2)`](https://pubs.opengroup.org/onlinepubs/9699919799/functions/mq_open.html)
142-
// The mode.bits() cast is only lossless on some OSes
142+
// The mode.bits cast is only lossless on some OSes
143143
#[allow(clippy::cast_lossless)]
144144
pub fn mq_open(
145145
name: &CStr,

src/sys/stat.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ pub fn mknod<P: ?Sized + NixPath>(
177177
dev: dev_t,
178178
) -> Result<()> {
179179
let res = path.with_nix_path(|cstr| unsafe {
180-
libc::mknod(cstr.as_ptr(), kind.bits() | perm.bits() as mode_t, dev)
180+
libc::mknod(cstr.as_ptr(), kind.bits | perm.bits() as mode_t, dev)
181181
})?;
182182

183183
Errno::result(res).map(drop)
@@ -202,7 +202,7 @@ pub fn mknodat<P: ?Sized + NixPath>(
202202
libc::mknodat(
203203
dirfd,
204204
cstr.as_ptr(),
205-
kind.bits() | perm.bits() as mode_t,
205+
kind.bits | perm.bits() as mode_t,
206206
dev,
207207
)
208208
})?;

src/sys/statvfs.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use crate::{errno::Errno, NixPath, Result};
1212
#[cfg(not(target_os = "redox"))]
1313
libc_bitflags!(
1414
/// File system mount Flags
15+
#[repr(C)]
1516
#[derive(Default)]
1617
pub struct FsFlags: c_ulong {
1718
/// Read Only

src/sys/termios.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ impl Termios {
309309
let termios = *self.inner.borrow_mut();
310310
self.input_flags = InputFlags::from_bits_truncate(termios.c_iflag);
311311
self.output_flags = OutputFlags::from_bits_truncate(termios.c_oflag);
312-
self.control_flags = ControlFlags::from_bits_retain(termios.c_cflag);
312+
self.control_flags = ControlFlags::from_bits_truncate(termios.c_cflag);
313313
self.local_flags = LocalFlags::from_bits_truncate(termios.c_lflag);
314314
self.control_chars = termios.c_cc;
315315
#[cfg(any(
@@ -355,9 +355,9 @@ libc_enum! {
355355
/// enum.
356356
///
357357
/// B0 is special and will disable the port.
358-
#[cfg_attr(target_os = "haiku", repr(u8))]
358+
#[cfg_attr(all(any(target_os = "haiku"), target_pointer_width = "64"), repr(u8))]
359359
#[cfg_attr(all(any(target_os = "ios", target_os = "macos"), target_pointer_width = "64"), repr(u64))]
360-
#[cfg_attr(all(not(all(any(target_os = "ios", target_os = "macos"), target_pointer_width = "64")), not(target_os = "haiku")), repr(u32))]
360+
#[cfg_attr(not(all(any(target_os = "ios", target_os = "macos", target_os = "haiku"), target_pointer_width = "64")), repr(u32))]
361361
#[non_exhaustive]
362362
pub enum BaudRate {
363363
B0,

src/sys/time.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ pub(crate) mod timer {
9191
#[cfg(any(target_os = "android", target_os = "linux"))]
9292
bitflags! {
9393
/// Flags that are used for arming the timer.
94-
#[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
9594
pub struct TimerSetTimeFlags: libc::c_int {
9695
const TFD_TIMER_ABSTIME = libc::TFD_TIMER_ABSTIME;
9796
}
@@ -104,7 +103,6 @@ pub(crate) mod timer {
104103
))]
105104
bitflags! {
106105
/// Flags that are used for arming the timer.
107-
#[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
108106
pub struct TimerSetTimeFlags: libc::c_int {
109107
const TFD_TIMER_ABSTIME = libc::TIMER_ABSTIME;
110108
}

src/unistd.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2906,7 +2906,7 @@ feature! {
29062906
pub fn access<P: ?Sized + NixPath>(path: &P, amode: AccessFlags) -> Result<()> {
29072907
let res = path.with_nix_path(|cstr| {
29082908
unsafe {
2909-
libc::access(cstr.as_ptr(), amode.bits())
2909+
libc::access(cstr.as_ptr(), amode.bits)
29102910
}
29112911
})?;
29122912
Errno::result(res).map(drop)
@@ -2947,7 +2947,7 @@ pub fn faccessat<P: ?Sized + NixPath>(dirfd: Option<RawFd>, path: &P, mode: Acce
29472947
pub fn eaccess<P: ?Sized + NixPath>(path: &P, mode: AccessFlags) -> Result<()> {
29482948
let res = path.with_nix_path(|cstr| {
29492949
unsafe {
2950-
libc::eaccess(cstr.as_ptr(), mode.bits())
2950+
libc::eaccess(cstr.as_ptr(), mode.bits)
29512951
}
29522952
})?;
29532953
Errno::result(res).map(drop)

0 commit comments

Comments
 (0)