From 62412486e874e16c4d727265ddc52e48807cb3e2 Mon Sep 17 00:00:00 2001 From: Aaron Kutch Date: Sat, 7 Nov 2020 13:09:51 -0600 Subject: [PATCH] fix some clippy warnings --- src/int/mod.rs | 4 ++-- src/mem/impls.rs | 8 +++----- src/mem/mod.rs | 4 ++-- src/mem/x86_64.rs | 4 ++-- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/int/mod.rs b/src/int/mod.rs index 24e8c3c3..5be5fb97 100644 --- a/src/int/mod.rs +++ b/src/int/mod.rs @@ -429,14 +429,14 @@ macro_rules! impl_wide_int { fn wide_shift_left(&mut self, low: &mut Self, count: i32) { *self = (*self << count) | (*low >> ($bits - count)); - *low = *low << count; + *low <<= count; } fn wide_shift_right_with_sticky(&mut self, low: &mut Self, count: i32) { if count < $bits { let sticky = *low << ($bits - count); *low = *self << ($bits - count) | *low >> count | sticky; - *self = *self >> count; + *self >>= count; } else if count < 2 * $bits { let sticky = *self << (2 * $bits - count) | *low; *low = *self >> (count - $bits) | sticky; diff --git a/src/mem/impls.rs b/src/mem/impls.rs index 6bd1a7ba..b3eef990 100644 --- a/src/mem/impls.rs +++ b/src/mem/impls.rs @@ -1,10 +1,8 @@ -use super::c_int; - #[inline(always)] pub unsafe fn copy_forward(dest: *mut u8, src: *const u8, n: usize) { let mut i = 0; while i < n { - *dest.offset(i as isize) = *src.offset(i as isize); + *dest.add(i) = *src.add(i); i += 1; } } @@ -15,7 +13,7 @@ pub unsafe fn copy_backward(dest: *mut u8, src: *const u8, n: usize) { let mut i = n; while i != 0 { i -= 1; - *dest.offset(i as isize) = *src.offset(i as isize); + *dest.add(i) = *src.add(i); } } @@ -23,7 +21,7 @@ pub unsafe fn copy_backward(dest: *mut u8, src: *const u8, n: usize) { pub unsafe fn set_bytes(s: *mut u8, c: u8, n: usize) { let mut i = 0; while i < n { - *s.offset(i as isize) = c; + *s.add(i) = c; i += 1; } } diff --git a/src/mem/mod.rs b/src/mem/mod.rs index adb7c2c6..107762c4 100644 --- a/src/mem/mod.rs +++ b/src/mem/mod.rs @@ -45,8 +45,8 @@ pub unsafe extern "C" fn memset(s: *mut u8, c: c_int, n: usize) -> *mut u8 { pub unsafe extern "C" fn memcmp(s1: *const u8, s2: *const u8, n: usize) -> i32 { let mut i = 0; while i < n { - let a = *s1.offset(i as isize); - let b = *s2.offset(i as isize); + let a = *s1.add(i); + let b = *s2.add(i); if a != b { return a as i32 - b as i32; } diff --git a/src/mem/x86_64.rs b/src/mem/x86_64.rs index 7eefd809..8cbbdf77 100644 --- a/src/mem/x86_64.rs +++ b/src/mem/x86_64.rs @@ -59,8 +59,8 @@ pub unsafe fn copy_backward(dest: *mut u8, src: *const u8, count: usize) { "cld", byte_count = in(reg) byte_count, inout("rcx") qword_count => _, - inout("rdi") dest.offset(count as isize).wrapping_sub(8) => _, - inout("rsi") src.offset(count as isize).wrapping_sub(8) => _, + inout("rdi") dest.add(count).wrapping_sub(8) => _, + inout("rsi") src.add(count).wrapping_sub(8) => _, options(nostack) ); }