summary refs log tree commit diff
path: root/kvm/src/lib.rs
diff options
context:
space:
mode:
authorDmitry Torokhov <dtor@chromium.org>2018-02-27 10:26:34 -0800
committerchrome-bot <chrome-bot@chromium.org>2018-02-27 20:17:08 -0800
commit93b00ecca772569727679e5026850810021be1ec (patch)
treeeddc391a7b6a7db2630e82249bf08f8b29963a0d /kvm/src/lib.rs
parent8283248a6084020ce58daf05d096314520881fe0 (diff)
downloadcrosvm-93b00ecca772569727679e5026850810021be1ec.tar
crosvm-93b00ecca772569727679e5026850810021be1ec.tar.gz
crosvm-93b00ecca772569727679e5026850810021be1ec.tar.bz2
crosvm-93b00ecca772569727679e5026850810021be1ec.tar.lz
crosvm-93b00ecca772569727679e5026850810021be1ec.tar.xz
crosvm-93b00ecca772569727679e5026850810021be1ec.tar.zst
crosvm-93b00ecca772569727679e5026850810021be1ec.zip
kvm: do not use negative error coded for errno-based errors
Errors derived from sysem errors delivered via -1 return code/errno
should use positive error codes, not negative, in order for them to be
recognized by other components. I.e. we should use
errno::Error::new(EINVAL) and not -EINVAL.

TEST=cargo test --features plugin; cargo test -p kvm
BUG=None

Change-Id: Ibe91745c36765c64aeab2f6aae5cd0ca8f243a42
Signed-off-by: Dmitry Torokhov <dtor@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/939868
Reviewed-by: Zach Reizner <zachr@chromium.org>
Diffstat (limited to 'kvm/src/lib.rs')
-rw-r--r--kvm/src/lib.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/kvm/src/lib.rs b/kvm/src/lib.rs
index d87bc76..1c75010 100644
--- a/kvm/src/lib.rs
+++ b/kvm/src/lib.rs
@@ -299,7 +299,7 @@ impl Vm {
                 self.mem_slot_gaps.push(-(slot as i32));
                 Ok(entry.remove())
             }
-            _ => Err(Error::new(-ENOENT))
+            _ => Err(Error::new(ENOENT))
         }
     }
 
@@ -314,7 +314,7 @@ impl Vm {
             Some(mmap) => {
                 // Ensures that there are as many bytes in dirty_log as there are pages in the mmap.
                 if dirty_log_bitmap_size(mmap.size()) > dirty_log.len() {
-                    return Err(Error::new(-EINVAL));
+                    return Err(Error::new(EINVAL));
                 }
                 let mut dirty_log_kvm = kvm_dirty_log {
                     slot,
@@ -327,7 +327,7 @@ impl Vm {
                 let ret = unsafe { ioctl_with_ref(self, KVM_GET_DIRTY_LOG(), &dirty_log_kvm) };
                 if ret == 0 { Ok(()) } else { errno_result() }
             }
-            _ => Err(Error::new(-ENOENT)),
+            _ => Err(Error::new(ENOENT)),
         }
     }