Skip to content

Commit

Permalink
fix: unaligned reference warnings
Browse files Browse the repository at this point in the history
Try re-generate code using c2rust 0.16, but still have these warnings.

Reference issues:
c2rust: `https://github.com/immunant/c2rust/issues/301`
rust-lang: `https://github.com/rust-lang/rust/issues/82523`
  • Loading branch information
zeroqn authored and jjyr committed Aug 10, 2022
1 parent 6c88968 commit 0378be8
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/blake2b_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ unsafe fn load64(mut src: *const libc::c_void) -> uint64_t {
#[inline]
unsafe fn store32(mut dst: *mut libc::c_void, mut w: uint32_t) {
let mut p: *mut uint8_t = dst as *mut uint8_t;
*p.offset(0 as libc::c_int as isize) = (w >> 0 as libc::c_int) as uint8_t;
*p.offset(1 as libc::c_int as isize) = (w >> 8 as libc::c_int) as uint8_t;
*p.offset(2 as libc::c_int as isize) = (w >> 16 as libc::c_int) as uint8_t;
*p.offset(3 as libc::c_int as isize) = (w >> 24 as libc::c_int) as uint8_t;
p.offset(0 as libc::c_int as isize).write_unaligned((w >> 0 as libc::c_int) as uint8_t);
p.offset(1 as libc::c_int as isize).write_unaligned((w >> 8 as libc::c_int) as uint8_t);
p.offset(2 as libc::c_int as isize).write_unaligned((w >> 16 as libc::c_int) as uint8_t);
p.offset(3 as libc::c_int as isize).write_unaligned((w >> 24 as libc::c_int) as uint8_t);
}
#[inline]
unsafe fn store64(mut dst: *mut libc::c_void, mut w: uint64_t) {
Expand Down Expand Up @@ -402,15 +402,15 @@ pub unsafe fn blake2b_init(mut S: *mut blake2b_state, mut outlen: size_t) -> lib
(*P.as_mut_ptr()).fanout = 1 as libc::c_int as uint8_t;
(*P.as_mut_ptr()).depth = 1 as libc::c_int as uint8_t;
store32(
&mut (*P.as_mut_ptr()).leaf_length as *mut uint32_t as *mut libc::c_void,
core::ptr::addr_of_mut!((*P.as_mut_ptr()).leaf_length) as *mut uint32_t as *mut libc::c_void,
0 as libc::c_int as uint32_t,
);
store32(
&mut (*P.as_mut_ptr()).node_offset as *mut uint32_t as *mut libc::c_void,
core::ptr::addr_of_mut!((*P.as_mut_ptr()).node_offset) as *mut uint32_t as *mut libc::c_void,
0 as libc::c_int as uint32_t,
);
store32(
&mut (*P.as_mut_ptr()).xof_length as *mut uint32_t as *mut libc::c_void,
core::ptr::addr_of_mut!((*P.as_mut_ptr()).xof_length) as *mut uint32_t as *mut libc::c_void,
0 as libc::c_int as uint32_t,
);
(*P.as_mut_ptr()).node_depth = 0 as libc::c_int as uint8_t;
Expand Down Expand Up @@ -458,15 +458,15 @@ pub unsafe fn blake2b_init_key(
(*P.as_mut_ptr()).fanout = 1 as libc::c_int as uint8_t;
(*P.as_mut_ptr()).depth = 1 as libc::c_int as uint8_t;
store32(
&mut (*P.as_mut_ptr()).leaf_length as *mut uint32_t as *mut libc::c_void,
core::ptr::addr_of_mut!((*P.as_mut_ptr()).leaf_length) as *mut uint32_t as *mut libc::c_void,
0 as libc::c_int as uint32_t,
);
store32(
&mut (*P.as_mut_ptr()).node_offset as *mut uint32_t as *mut libc::c_void,
core::ptr::addr_of_mut!((*P.as_mut_ptr()).node_offset) as *mut uint32_t as *mut libc::c_void,
0 as libc::c_int as uint32_t,
);
store32(
&mut (*P.as_mut_ptr()).xof_length as *mut uint32_t as *mut libc::c_void,
core::ptr::addr_of_mut!((*P.as_mut_ptr()).xof_length) as *mut uint32_t as *mut libc::c_void,
0 as libc::c_int as uint32_t,
);
(*P.as_mut_ptr()).node_depth = 0 as libc::c_int as uint8_t;
Expand Down

0 comments on commit 0378be8

Please sign in to comment.