]> git.lizzy.rs Git - rust.git/commitdiff
Fix casts for `count` check
authorChristian Poveda <christianpoveda@protonmail.com>
Sun, 3 Nov 2019 16:04:00 +0000 (10:04 -0600)
committerChristian Poveda <christianpoveda@protonmail.com>
Sun, 3 Nov 2019 16:04:00 +0000 (10:04 -0600)
src/shims/fs.rs

index 2710cbacb0213e90cfacfc14c9d06297d13ff52f..66e24eb8b09245c78b89d3589ce127549548b635 100644 (file)
@@ -146,7 +146,7 @@ fn close(&mut self, fd_op: OpTy<'tcx, Tag>) -> InterpResult<'tcx, i32> {
             // `File::sync_all` does the checks that are done when closing a file. We do this to
             // to handle possible errors correctly.
             let result = this.try_unwrap_io_result(handle.file.sync_all().map(|_| 0i32));
-            // Now we actually drop the handle.
+            // Now we actually close the file.
             drop(handle);
             // And return the result.
             result
@@ -180,7 +180,7 @@ fn read(
 
             if let Ok(c) = result {
                 // Check that we read less than `i64::MAX` bytes.
-                if c > (i64::max_value() as usize) {
+                if (c as u64) > (i64::max_value() as u64) {
                     throw_unsup_format!("Number of read bytes {} is larger than the maximum value", c);
                 }
                 // If reading to `bytes` did not fail, we write those bytes to the buffer.
@@ -217,7 +217,7 @@ fn write(
 
             if let Ok(c) = result {
                 // Check that we wrote less than `i64::MAX` bytes.
-                if c > (i64::max_value() as usize) {
+                if (c as u64) > (i64::max_value() as u64) {
                     throw_unsup_format!("Number of written bytes {} is larger than the maximum value", c);
                 }
             }