Skip to content

Commit

Permalink
fix some clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronKutch committed Nov 23, 2020
1 parent ba68020 commit 6241248
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/int/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 3 additions & 5 deletions src/mem/impls.rs
Original file line number Diff line number Diff line change
@@ -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;
}
}
Expand All @@ -15,15 +13,15 @@ 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);
}
}

#[inline(always)]
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;
}
}
4 changes: 2 additions & 2 deletions src/mem/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions src/mem/x86_64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
);
}
Expand Down

0 comments on commit 6241248

Please sign in to comment.