summary refs log tree commit diff
path: root/sys_util/src/ioctl.rs
diff options
context:
space:
mode:
authorZach Reizner <zachr@google.com>2018-10-03 10:22:32 -0700
committerchrome-bot <chrome-bot@chromium.org>2018-10-09 21:14:05 -0700
commit55a9e504beef368bd97e51ffd5a7fa6c034eb8ad (patch)
tree894d8685e2fdfa105ea35d1cb6cfceee06502c7a /sys_util/src/ioctl.rs
parent046df60760f3b0691f23c27a7f24a96c9afe8c05 (diff)
downloadcrosvm-55a9e504beef368bd97e51ffd5a7fa6c034eb8ad.tar
crosvm-55a9e504beef368bd97e51ffd5a7fa6c034eb8ad.tar.gz
crosvm-55a9e504beef368bd97e51ffd5a7fa6c034eb8ad.tar.bz2
crosvm-55a9e504beef368bd97e51ffd5a7fa6c034eb8ad.tar.lz
crosvm-55a9e504beef368bd97e51ffd5a7fa6c034eb8ad.tar.xz
crosvm-55a9e504beef368bd97e51ffd5a7fa6c034eb8ad.tar.zst
crosvm-55a9e504beef368bd97e51ffd5a7fa6c034eb8ad.zip
cargo fmt all source code
Now that cargo fmt has landed, run it over everything at once to bring
rust source to the standard formatting.

TEST=cargo test
BUG=None

Change-Id: Ic95a48725e5a40dcbd33ba6d5aef2bd01e91865b
Reviewed-on: https://chromium-review.googlesource.com/1259287
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Diffstat (limited to 'sys_util/src/ioctl.rs')
-rw-r--r--sys_util/src/ioctl.rs62
1 files changed, 40 insertions, 22 deletions
diff --git a/sys_util/src/ioctl.rs b/sys_util/src/ioctl.rs
index edfa3be..31d21c9 100644
--- a/sys_util/src/ioctl.rs
+++ b/sys_util/src/ioctl.rs
@@ -12,47 +12,65 @@ use libc;
 /// Raw macro to declare a function that returns an ioctl number.
 #[macro_export]
 macro_rules! ioctl_ioc_nr {
-    ($name:ident, $dir:expr, $ty:expr, $nr:expr, $size:expr) => (
+    ($name:ident, $dir:expr, $ty:expr, $nr:expr, $size:expr) => {
         #[allow(non_snake_case)]
         pub fn $name() -> ::std::os::raw::c_ulong {
-            (($dir << $crate::ioctl::_IOC_DIRSHIFT) |
-            ($ty << $crate::ioctl::_IOC_TYPESHIFT) |
-            ($nr<< $crate::ioctl::_IOC_NRSHIFT) |
-            ($size << $crate::ioctl::_IOC_SIZESHIFT)) as ::std::os::raw::c_ulong
+            (($dir << $crate::ioctl::_IOC_DIRSHIFT)
+                | ($ty << $crate::ioctl::_IOC_TYPESHIFT)
+                | ($nr << $crate::ioctl::_IOC_NRSHIFT)
+                | ($size << $crate::ioctl::_IOC_SIZESHIFT)) as ::std::os::raw::c_ulong
         }
-    )
+    };
 }
 
 /// Declare an ioctl that transfers no data.
 #[macro_export]
 macro_rules! ioctl_io_nr {
-    ($name:ident, $ty:expr, $nr:expr) => (
+    ($name:ident, $ty:expr, $nr:expr) => {
         ioctl_ioc_nr!($name, $crate::ioctl::_IOC_NONE, $ty, $nr, 0);
-    )
+    };
 }
 
 /// Declare an ioctl that reads data.
 #[macro_export]
 macro_rules! ioctl_ior_nr {
-    ($name:ident, $ty:expr, $nr:expr, $size:ty) => (
-        ioctl_ioc_nr!($name, $crate::ioctl::_IOC_READ, $ty, $nr, ::std::mem::size_of::<$size>() as u32);
-    )
+    ($name:ident, $ty:expr, $nr:expr, $size:ty) => {
+        ioctl_ioc_nr!(
+            $name,
+            $crate::ioctl::_IOC_READ,
+            $ty,
+            $nr,
+            ::std::mem::size_of::<$size>() as u32
+        );
+    };
 }
 
 /// Declare an ioctl that writes data.
 #[macro_export]
 macro_rules! ioctl_iow_nr {
-    ($name:ident, $ty:expr, $nr:expr, $size:ty) => (
-        ioctl_ioc_nr!($name, $crate::ioctl::_IOC_WRITE, $ty, $nr, ::std::mem::size_of::<$size>() as u32);
-    )
+    ($name:ident, $ty:expr, $nr:expr, $size:ty) => {
+        ioctl_ioc_nr!(
+            $name,
+            $crate::ioctl::_IOC_WRITE,
+            $ty,
+            $nr,
+            ::std::mem::size_of::<$size>() as u32
+        );
+    };
 }
 
 /// Declare an ioctl that reads and writes data.
 #[macro_export]
 macro_rules! ioctl_iowr_nr {
-    ($name:ident, $ty:expr, $nr:expr, $size:ty) => (
-        ioctl_ioc_nr!($name, $crate::ioctl::_IOC_READ | $crate::ioctl::_IOC_WRITE, $ty, $nr, ::std::mem::size_of::<$size>() as u32);
-    )
+    ($name:ident, $ty:expr, $nr:expr, $size:ty) => {
+        ioctl_ioc_nr!(
+            $name,
+            $crate::ioctl::_IOC_READ | $crate::ioctl::_IOC_WRITE,
+            $ty,
+            $nr,
+            ::std::mem::size_of::<$size>() as u32
+        );
+    };
 }
 
 pub const _IOC_NRBITS: c_uint = 8;
@@ -109,12 +127,12 @@ pub unsafe fn ioctl_with_mut_ptr<F: AsRawFd, T>(fd: &F, nr: c_ulong, arg: *mut T
 #[cfg(test)]
 mod tests {
     const TUNTAP: ::std::os::raw::c_uint = 0x54;
-    const VHOST:  ::std::os::raw::c_uint = 0xaf;
+    const VHOST: ::std::os::raw::c_uint = 0xaf;
 
-    ioctl_io_nr!(VHOST_SET_OWNER,        VHOST,  0x01);
-    ioctl_ior_nr!(TUNGETFEATURES,        TUNTAP, 0xcf, ::std::os::raw::c_uint);
-    ioctl_iow_nr!(TUNSETQUEUE,           TUNTAP, 0xd9, ::std::os::raw::c_int);
-    ioctl_iowr_nr!(VHOST_GET_VRING_BASE, VHOST,  0x12, ::std::os::raw::c_int);
+    ioctl_io_nr!(VHOST_SET_OWNER, VHOST, 0x01);
+    ioctl_ior_nr!(TUNGETFEATURES, TUNTAP, 0xcf, ::std::os::raw::c_uint);
+    ioctl_iow_nr!(TUNSETQUEUE, TUNTAP, 0xd9, ::std::os::raw::c_int);
+    ioctl_iowr_nr!(VHOST_GET_VRING_BASE, VHOST, 0x12, ::std::os::raw::c_int);
 
     #[test]
     fn ioctl_macros() {