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 Dec 2, 2020
1 parent f7c78b9 commit 572a6b1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
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 572a6b1

Please sign in to comment.