Skip to content

Commit c6c7024

Browse files
committed
Fix clippy errors
1 parent 7aa0fdb commit c6c7024

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

libcc2rs/src/io.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ pub fn fread_refcount(a0: AnyPtr, a1: u64, a2: u64, a3: Ptr<::std::fs::File>) ->
8585
Err(e) => panic!("Unhandled error in fread: {e}"),
8686
};
8787

88-
for i in 0..n {
89-
dst.write(buffer[i]);
88+
for &byte in &buffer[..n] {
89+
dst.write(byte);
9090
dst = dst.offset(1);
9191
}
9292

@@ -96,6 +96,10 @@ pub fn fread_refcount(a0: AnyPtr, a1: u64, a2: u64, a3: Ptr<::std::fs::File>) ->
9696
(read_bytes / a1 as usize) as u64
9797
}
9898

99+
/// # Safety
100+
///
101+
/// `a0` must point to a writable buffer of at least `a1 * a2` bytes, and `a3`
102+
/// must point to a valid, open `std::fs::File`.
99103
pub unsafe fn fread_unsafe(
100104
a0: *mut ::std::ffi::c_void,
101105
a1: u64,
@@ -122,9 +126,9 @@ pub unsafe fn fread_unsafe(
122126
Err(e) => panic!("Unhandled error in fread: {e}"),
123127
};
124128

125-
for i in 0..n {
129+
for &byte in &buffer[..n] {
126130
unsafe {
127-
*dst = buffer[i];
131+
*dst = byte;
128132
dst = dst.offset(1);
129133
}
130134
}

0 commit comments

Comments
 (0)