From 53a03cb0ba01590211f99aec84ae58977414e532 Mon Sep 17 00:00:00 2001
From: Tom Almeida <tommoa256@gmail.com>
Date: Tue, 3 Jul 2018 14:50:38 +0800
Subject: [PATCH] Made sure errors were properly handled by printf

---
 src/stdio/src/printf.rs | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/stdio/src/printf.rs b/src/stdio/src/printf.rs
index 813213f4..aa9af15f 100644
--- a/src/stdio/src/printf.rs
+++ b/src/stdio/src/printf.rs
@@ -15,7 +15,7 @@ pub unsafe fn printf<W: Write>(mut w: W, format: *const c_char, mut ap: VaList)
         }
 
         if found_percent {
-            match b as char {
+            if match b as char {
                 '%' => {
                     found_percent = false;
                     w.write_char('%')
@@ -97,11 +97,15 @@ pub unsafe fn printf<W: Write>(mut w: W, format: *const c_char, mut ap: VaList)
                 '#' => Ok(()),
                 '0'...'9' => Ok(()),
                 _ => Ok(()),
-            }.map_err(|_| return -1).unwrap()
+            }.is_err() {
+                return -1;
+            }
         } else if b == b'%' {
             found_percent = true;
         } else {
-            w.write_u8(b).map_err(|_| return -1).unwrap()
+            if w.write_u8(b).is_err() {
+                return -1;
+            }
         }
     }
 
-- 
GitLab