summary refs log tree commit diff
path: root/sys_util/src/handle_eintr.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/handle_eintr.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/handle_eintr.rs')
-rw-r--r--sys_util/src/handle_eintr.rs84
1 files changed, 45 insertions, 39 deletions
diff --git a/sys_util/src/handle_eintr.rs b/sys_util/src/handle_eintr.rs
index 4bf16da..4faab07 100644
--- a/sys_util/src/handle_eintr.rs
+++ b/sys_util/src/handle_eintr.rs
@@ -120,22 +120,20 @@ impl<T> InterruptibleResult for io::Result<T> {
 /// ```
 #[macro_export]
 macro_rules! handle_eintr {
-    ($x:expr) => (
-        {
-            use $crate::handle_eintr::InterruptibleResult;
-            let res;
-            loop {
-                match $x {
-                    ref v if v.is_interrupted() => continue,
-                    v => {
-                        res = v;
-                        break;
-                    }
+    ($x:expr) => {{
+        use $crate::handle_eintr::InterruptibleResult;
+        let res;
+        loop {
+            match $x {
+                ref v if v.is_interrupted() => continue,
+                v => {
+                    res = v;
+                    break;
                 }
             }
-            res
         }
-    )
+        res
+    }};
 }
 
 /// Macro that retries the given expression every time its result indicates it was interrupted.
@@ -144,19 +142,17 @@ macro_rules! handle_eintr {
 /// Most of reentrant functions use this way of signalling errors.
 #[macro_export]
 macro_rules! handle_eintr_rc {
-    ($x:expr) => (
-        {
-            use libc::EINTR;
-            let mut res;
-            loop {
-                res = $x;
-                if res != EINTR {
-                    break;
-                }
+    ($x:expr) => {{
+        use libc::EINTR;
+        let mut res;
+        loop {
+            res = $x;
+            if res != EINTR {
+                break;
             }
-            res
         }
-    )
+        res
+    }};
 }
 
 /// Macro that retries the given expression every time its result indicates it was interrupted.
@@ -165,20 +161,18 @@ macro_rules! handle_eintr_rc {
 /// Most of standard non-reentrant libc functions use this way of signalling errors.
 #[macro_export]
 macro_rules! handle_eintr_errno {
-    ($x:expr) => (
-        {
-            use $crate::Error;
-            use libc::EINTR;
-            let mut res;
-            loop {
-                res = $x;
-                if res != -1 || Error::last() != Error::new(EINTR) {
-                    break;
-                }
+    ($x:expr) => {{
+        use libc::EINTR;
+        use $crate::Error;
+        let mut res;
+        loop {
+            res = $x;
+            if res != -1 || Error::last() != Error::new(EINTR) {
+                break;
             }
-            res
         }
-    )
+        res
+    }};
 }
 
 #[cfg(test)]
@@ -194,7 +188,11 @@ mod tests {
         {
             let mut dummy = || {
                 count -= 1;
-                if count > 0 { EINTR } else { 0 }
+                if count > 0 {
+                    EINTR
+                } else {
+                    0
+                }
             };
             let res = handle_eintr_rc!(dummy());
             assert_eq!(res, 0);
@@ -208,7 +206,12 @@ mod tests {
         {
             let mut dummy = || {
                 count -= 1;
-                if count > 0 { set_errno(EINTR); -1 } else { 56 }
+                if count > 0 {
+                    set_errno(EINTR);
+                    -1
+                } else {
+                    56
+                }
             };
             let res = handle_eintr_errno!(dummy());
             assert_eq!(res, 56);
@@ -241,7 +244,10 @@ mod tests {
             let mut dummy = || {
                 count -= 1;
                 if count > 99 {
-                    Err(io::Error::new(io::ErrorKind::Interrupted, "interrupted again :("))
+                    Err(io::Error::new(
+                        io::ErrorKind::Interrupted,
+                        "interrupted again :(",
+                    ))
                 } else {
                     Ok(32)
                 }