Skip to content

Commit 3e6cb63

Browse files
committed
Fix all formating problems to pass CI formating test
Signed-off-by: Costin-Robert Sin <sin.costinrobert@gmail.com>
1 parent 8f08a69 commit 3e6cb63

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+4348
-2961
lines changed

src/errno.rs

Lines changed: 1664 additions & 1292 deletions
Large diffs are not rendered by default.

src/fcntl.rs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,10 @@ use std::os::raw;
66
use std::os::unix::ffi::OsStringExt;
77
use std::os::unix::io::RawFd;
88

9+
#[cfg(feature = "fs")]
10+
use crate::{sys::stat::Mode, NixPath, Result};
911
#[cfg(any(target_os = "android", target_os = "linux"))]
1012
use std::ptr; // For splice and copy_file_range
11-
#[cfg(feature = "fs")]
12-
use crate::{
13-
NixPath,
14-
Result,
15-
sys::stat::Mode
16-
};
1713

1814
#[cfg(any(
1915
target_os = "linux",
@@ -25,7 +21,7 @@ use crate::{
2521
target_os = "freebsd"
2622
))]
2723
#[cfg(feature = "fs")]
28-
pub use self::posix_fadvise::{PosixFadviseAdvice, posix_fadvise};
24+
pub use self::posix_fadvise::{posix_fadvise, PosixFadviseAdvice};
2925

3026
#[cfg(not(target_os = "redox"))]
3127
#[cfg(any(feature = "fs", feature = "process"))]
@@ -241,10 +237,7 @@ pub fn renameat<P1: ?Sized + NixPath, P2: ?Sized + NixPath>(
241237
}
242238
}
243239

244-
#[cfg(all(
245-
target_os = "linux",
246-
target_env = "gnu",
247-
))]
240+
#[cfg(all(target_os = "linux", target_env = "gnu",))]
248241
#[cfg(feature = "fs")]
249242
libc_bitflags! {
250243
#[cfg_attr(docsrs, doc(cfg(feature = "fs")))]

src/lib.rs

Lines changed: 37 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,14 @@
5252
#![deny(missing_copy_implementations)]
5353
#![deny(missing_debug_implementations)]
5454
#![warn(missing_docs)]
55-
5655
#![cfg_attr(docsrs, feature(doc_cfg))]
5756

5857
// Re-exported external crates
5958
pub use libc;
6059

6160
// Private internal modules
62-
#[macro_use] mod macros;
61+
#[macro_use]
62+
mod macros;
6363

6464
// Public crates
6565
#[cfg(not(target_os = "redox"))]
@@ -100,24 +100,23 @@ feature! {
100100
#[deny(missing_docs)]
101101
pub mod net;
102102
}
103-
#[cfg(any(target_os = "android",
104-
target_os = "linux"))]
103+
#[cfg(any(target_os = "android", target_os = "linux"))]
105104
feature! {
106105
#![feature = "kmod"]
107106
#[allow(missing_docs)]
108107
pub mod kmod;
109108
}
110-
#[cfg(any(target_os = "android",
111-
target_os = "freebsd",
112-
target_os = "linux"))]
109+
#[cfg(any(target_os = "android", target_os = "freebsd", target_os = "linux"))]
113110
feature! {
114111
#![feature = "mount"]
115112
pub mod mount;
116113
}
117-
#[cfg(any(target_os = "dragonfly",
118-
target_os = "freebsd",
119-
target_os = "linux",
120-
target_os = "netbsd"))]
114+
#[cfg(any(
115+
target_os = "dragonfly",
116+
target_os = "freebsd",
117+
target_os = "linux",
118+
target_os = "netbsd"
119+
))]
121120
feature! {
122121
#![feature = "mqueue"]
123122
#[allow(missing_docs)]
@@ -145,9 +144,10 @@ feature! {
145144
}
146145
// This can be implemented for other platforms as soon as libc
147146
// provides bindings for them.
148-
#[cfg(all(target_os = "linux",
149-
any(target_arch = "s390x", target_arch = "x86",
150-
target_arch = "x86_64")))]
147+
#[cfg(all(
148+
target_os = "linux",
149+
any(target_arch = "s390x", target_arch = "x86", target_arch = "x86_64")
150+
))]
151151
feature! {
152152
#![feature = "ucontext"]
153153
#[allow(missing_docs)]
@@ -191,7 +191,8 @@ pub trait NixPath {
191191
///
192192
/// Mostly used internally by Nix.
193193
fn with_nix_path<T, F>(&self, f: F) -> Result<T>
194-
where F: FnOnce(&CStr) -> T;
194+
where
195+
F: FnOnce(&CStr) -> T;
195196
}
196197

197198
impl NixPath for str {
@@ -204,9 +205,11 @@ impl NixPath for str {
204205
}
205206

206207
fn with_nix_path<T, F>(&self, f: F) -> Result<T>
207-
where F: FnOnce(&CStr) -> T {
208-
OsStr::new(self).with_nix_path(f)
209-
}
208+
where
209+
F: FnOnce(&CStr) -> T,
210+
{
211+
OsStr::new(self).with_nix_path(f)
212+
}
210213
}
211214

212215
impl NixPath for OsStr {
@@ -219,9 +222,11 @@ impl NixPath for OsStr {
219222
}
220223

221224
fn with_nix_path<T, F>(&self, f: F) -> Result<T>
222-
where F: FnOnce(&CStr) -> T {
223-
self.as_bytes().with_nix_path(f)
224-
}
225+
where
226+
F: FnOnce(&CStr) -> T,
227+
{
228+
self.as_bytes().with_nix_path(f)
229+
}
225230
}
226231

227232
impl NixPath for CStr {
@@ -274,7 +279,9 @@ impl NixPath for [u8] {
274279
buf_ptr.add(self.len()).write(0);
275280
}
276281

277-
match CStr::from_bytes_with_nul(unsafe { slice::from_raw_parts(buf_ptr, self.len() + 1) }) {
282+
match CStr::from_bytes_with_nul(unsafe {
283+
slice::from_raw_parts(buf_ptr, self.len() + 1)
284+
}) {
278285
Ok(s) => Ok(f(s)),
279286
Err(_) => Err(Errno::EINVAL),
280287
}
@@ -302,7 +309,10 @@ impl NixPath for Path {
302309
NixPath::len(self.as_os_str())
303310
}
304311

305-
fn with_nix_path<T, F>(&self, f: F) -> Result<T> where F: FnOnce(&CStr) -> T {
312+
fn with_nix_path<T, F>(&self, f: F) -> Result<T>
313+
where
314+
F: FnOnce(&CStr) -> T,
315+
{
306316
self.as_os_str().with_nix_path(f)
307317
}
308318
}
@@ -316,7 +326,10 @@ impl NixPath for PathBuf {
316326
NixPath::len(self.as_os_str())
317327
}
318328

319-
fn with_nix_path<T, F>(&self, f: F) -> Result<T> where F: FnOnce(&CStr) -> T {
329+
fn with_nix_path<T, F>(&self, f: F) -> Result<T>
330+
where
331+
F: FnOnce(&CStr) -> T,
332+
{
320333
self.as_os_str().with_nix_path(f)
321334
}
322335
}

src/sys/ioctl/bsd.rs

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ mod consts {
2121
#[allow(overflowing_literals)]
2222
pub const IN: ioctl_num_type = 0x8000_0000;
2323
#[doc(hidden)]
24-
pub const INOUT: ioctl_num_type = IN|OUT;
24+
pub const INOUT: ioctl_num_type = IN | OUT;
2525
#[doc(hidden)]
2626
pub const IOCPARM_MASK: ioctl_num_type = 0x1fff;
2727
}
@@ -31,9 +31,14 @@ pub use self::consts::*;
3131
#[macro_export]
3232
#[doc(hidden)]
3333
macro_rules! ioc {
34-
($inout:expr, $group:expr, $num:expr, $len:expr) => (
35-
$inout | (($len as $crate::sys::ioctl::ioctl_num_type & $crate::sys::ioctl::IOCPARM_MASK) << 16) | (($group as $crate::sys::ioctl::ioctl_num_type) << 8) | ($num as $crate::sys::ioctl::ioctl_num_type)
36-
)
34+
($inout:expr, $group:expr, $num:expr, $len:expr) => {
35+
$inout
36+
| (($len as $crate::sys::ioctl::ioctl_num_type
37+
& $crate::sys::ioctl::IOCPARM_MASK)
38+
<< 16)
39+
| (($group as $crate::sys::ioctl::ioctl_num_type) << 8)
40+
| ($num as $crate::sys::ioctl::ioctl_num_type)
41+
};
3742
}
3843

3944
/// Generate an ioctl request code for a command that passes no data.
@@ -53,7 +58,9 @@ macro_rules! ioc {
5358
/// ```
5459
#[macro_export(local_inner_macros)]
5560
macro_rules! request_code_none {
56-
($g:expr, $n:expr) => (ioc!($crate::sys::ioctl::VOID, $g, $n, 0))
61+
($g:expr, $n:expr) => {
62+
ioc!($crate::sys::ioctl::VOID, $g, $n, 0)
63+
};
5764
}
5865

5966
/// Generate an ioctl request code for a command that passes an integer
@@ -64,7 +71,14 @@ macro_rules! request_code_none {
6471
/// with is "bad" and you cannot use `ioctl_write_int!()` directly.
6572
#[macro_export(local_inner_macros)]
6673
macro_rules! request_code_write_int {
67-
($g:expr, $n:expr) => (ioc!($crate::sys::ioctl::VOID, $g, $n, ::std::mem::size_of::<$crate::libc::c_int>()))
74+
($g:expr, $n:expr) => {
75+
ioc!(
76+
$crate::sys::ioctl::VOID,
77+
$g,
78+
$n,
79+
::std::mem::size_of::<$crate::libc::c_int>()
80+
)
81+
};
6882
}
6983

7084
/// Generate an ioctl request code for a command that reads.
@@ -79,7 +93,9 @@ macro_rules! request_code_write_int {
7993
/// writing.
8094
#[macro_export(local_inner_macros)]
8195
macro_rules! request_code_read {
82-
($g:expr, $n:expr, $len:expr) => (ioc!($crate::sys::ioctl::OUT, $g, $n, $len))
96+
($g:expr, $n:expr, $len:expr) => {
97+
ioc!($crate::sys::ioctl::OUT, $g, $n, $len)
98+
};
8399
}
84100

85101
/// Generate an ioctl request code for a command that writes.
@@ -94,7 +110,9 @@ macro_rules! request_code_read {
94110
/// reading.
95111
#[macro_export(local_inner_macros)]
96112
macro_rules! request_code_write {
97-
($g:expr, $n:expr, $len:expr) => (ioc!($crate::sys::ioctl::IN, $g, $n, $len))
113+
($g:expr, $n:expr, $len:expr) => {
114+
ioc!($crate::sys::ioctl::IN, $g, $n, $len)
115+
};
98116
}
99117

100118
/// Generate an ioctl request code for a command that reads and writes.
@@ -105,5 +123,7 @@ macro_rules! request_code_write {
105123
/// with is "bad" and you cannot use `ioctl_readwrite!()` directly.
106124
#[macro_export(local_inner_macros)]
107125
macro_rules! request_code_readwrite {
108-
($g:expr, $n:expr, $len:expr) => (ioc!($crate::sys::ioctl::INOUT, $g, $n, $len))
126+
($g:expr, $n:expr, $len:expr) => {
127+
ioc!($crate::sys::ioctl::INOUT, $g, $n, $len)
128+
};
109129
}

src/sys/ioctl/linux.rs

Lines changed: 47 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,13 @@ pub const NRBITS: ioctl_num_type = 8;
1414
#[doc(hidden)]
1515
pub const TYPEBITS: ioctl_num_type = 8;
1616

17-
#[cfg(any(target_arch = "mips", target_arch = "mips64", target_arch = "powerpc", target_arch = "powerpc64", target_arch = "sparc64"))]
17+
#[cfg(any(
18+
target_arch = "mips",
19+
target_arch = "mips64",
20+
target_arch = "powerpc",
21+
target_arch = "powerpc64",
22+
target_arch = "sparc64"
23+
))]
1824
mod consts {
1925
#[doc(hidden)]
2026
pub const NONE: u8 = 1;
@@ -29,13 +35,15 @@ mod consts {
2935
}
3036

3137
// "Generic" ioctl protocol
32-
#[cfg(any(target_arch = "x86",
33-
target_arch = "arm",
34-
target_arch = "s390x",
35-
target_arch = "x86_64",
36-
target_arch = "aarch64",
37-
target_arch = "riscv32",
38-
target_arch = "riscv64"))]
38+
#[cfg(any(
39+
target_arch = "x86",
40+
target_arch = "arm",
41+
target_arch = "s390x",
42+
target_arch = "x86_64",
43+
target_arch = "aarch64",
44+
target_arch = "riscv32",
45+
target_arch = "riscv64"
46+
))]
3947
mod consts {
4048
#[doc(hidden)]
4149
pub const NONE: u8 = 0;
@@ -73,11 +81,20 @@ pub const DIRMASK: ioctl_num_type = (1 << DIRBITS) - 1;
7381
#[macro_export]
7482
#[doc(hidden)]
7583
macro_rules! ioc {
76-
($dir:expr, $ty:expr, $nr:expr, $sz:expr) => (
77-
(($dir as $crate::sys::ioctl::ioctl_num_type & $crate::sys::ioctl::DIRMASK) << $crate::sys::ioctl::DIRSHIFT) |
78-
(($ty as $crate::sys::ioctl::ioctl_num_type & $crate::sys::ioctl::TYPEMASK) << $crate::sys::ioctl::TYPESHIFT) |
79-
(($nr as $crate::sys::ioctl::ioctl_num_type & $crate::sys::ioctl::NRMASK) << $crate::sys::ioctl::NRSHIFT) |
80-
(($sz as $crate::sys::ioctl::ioctl_num_type & $crate::sys::ioctl::SIZEMASK) << $crate::sys::ioctl::SIZESHIFT))
84+
($dir:expr, $ty:expr, $nr:expr, $sz:expr) => {
85+
(($dir as $crate::sys::ioctl::ioctl_num_type
86+
& $crate::sys::ioctl::DIRMASK)
87+
<< $crate::sys::ioctl::DIRSHIFT)
88+
| (($ty as $crate::sys::ioctl::ioctl_num_type
89+
& $crate::sys::ioctl::TYPEMASK)
90+
<< $crate::sys::ioctl::TYPESHIFT)
91+
| (($nr as $crate::sys::ioctl::ioctl_num_type
92+
& $crate::sys::ioctl::NRMASK)
93+
<< $crate::sys::ioctl::NRSHIFT)
94+
| (($sz as $crate::sys::ioctl::ioctl_num_type
95+
& $crate::sys::ioctl::SIZEMASK)
96+
<< $crate::sys::ioctl::SIZESHIFT)
97+
};
8198
}
8299

83100
/// Generate an ioctl request code for a command that passes no data.
@@ -97,7 +114,9 @@ macro_rules! ioc {
97114
/// ```
98115
#[macro_export(local_inner_macros)]
99116
macro_rules! request_code_none {
100-
($ty:expr, $nr:expr) => (ioc!($crate::sys::ioctl::NONE, $ty, $nr, 0))
117+
($ty:expr, $nr:expr) => {
118+
ioc!($crate::sys::ioctl::NONE, $ty, $nr, 0)
119+
};
101120
}
102121

103122
/// Generate an ioctl request code for a command that reads.
@@ -112,7 +131,9 @@ macro_rules! request_code_none {
112131
/// writing.
113132
#[macro_export(local_inner_macros)]
114133
macro_rules! request_code_read {
115-
($ty:expr, $nr:expr, $sz:expr) => (ioc!($crate::sys::ioctl::READ, $ty, $nr, $sz))
134+
($ty:expr, $nr:expr, $sz:expr) => {
135+
ioc!($crate::sys::ioctl::READ, $ty, $nr, $sz)
136+
};
116137
}
117138

118139
/// Generate an ioctl request code for a command that writes.
@@ -127,7 +148,9 @@ macro_rules! request_code_read {
127148
/// reading.
128149
#[macro_export(local_inner_macros)]
129150
macro_rules! request_code_write {
130-
($ty:expr, $nr:expr, $sz:expr) => (ioc!($crate::sys::ioctl::WRITE, $ty, $nr, $sz))
151+
($ty:expr, $nr:expr, $sz:expr) => {
152+
ioc!($crate::sys::ioctl::WRITE, $ty, $nr, $sz)
153+
};
131154
}
132155

133156
/// Generate an ioctl request code for a command that reads and writes.
@@ -138,5 +161,12 @@ macro_rules! request_code_write {
138161
/// with is "bad" and you cannot use `ioctl_readwrite!()` directly.
139162
#[macro_export(local_inner_macros)]
140163
macro_rules! request_code_readwrite {
141-
($ty:expr, $nr:expr, $sz:expr) => (ioc!($crate::sys::ioctl::READ | $crate::sys::ioctl::WRITE, $ty, $nr, $sz))
164+
($ty:expr, $nr:expr, $sz:expr) => {
165+
ioc!(
166+
$crate::sys::ioctl::READ | $crate::sys::ioctl::WRITE,
167+
$ty,
168+
$nr,
169+
$sz
170+
)
171+
};
142172
}

0 commit comments

Comments
 (0)