diff --git a/iceoryx-sys/src/chunk_header.rs b/iceoryx-sys/src/chunk_header.rs index 2de051d..c08aae9 100644 --- a/iceoryx-sys/src/chunk_header.rs +++ b/iceoryx-sys/src/chunk_header.rs @@ -31,19 +31,19 @@ impl ChunkHeader { } } - pub fn get_user_payload_size(&self) -> u32 { + pub fn get_user_payload_size(&self) -> usize { unsafe { cpp!([self as "ChunkHeader*"] -> u32 as "uint32_t" { return self->userPayloadSize(); - }) + }) as usize } } - pub fn get_user_payload_alignment(&self) -> u32 { + pub fn get_user_payload_alignment(&self) -> usize { unsafe { cpp!([self as "ChunkHeader*"] -> u32 as "uint32_t" { return self->userPayloadAlignment(); - }) + }) as usize } } } diff --git a/iceoryx-sys/src/subscriber.rs b/iceoryx-sys/src/subscriber.rs index ab6bce0..c3b7368 100644 --- a/iceoryx-sys/src/subscriber.rs +++ b/iceoryx-sys/src/subscriber.rs @@ -255,15 +255,12 @@ impl Subscriber { let chunk_header = payload.chunk_header(); let payload_size = chunk_header.get_user_payload_size(); let payload_alignment = chunk_header.get_user_payload_alignment(); - let len = payload_size as usize / std::mem::size_of::(); + let len = payload_size / std::mem::size_of::(); - if payload_size as usize % std::mem::size_of::() == 0 - && payload_alignment as usize >= std::mem::align_of::() + if payload_size % std::mem::size_of::() == 0 + && payload_alignment >= std::mem::align_of::() { - Some(RawSample::slice_from_raw_parts( - payload.cast::(), - len as usize, - )) + Some(RawSample::slice_from_raw_parts(payload.cast::(), len)) } else { // TODO return Result> self.release(payload); diff --git a/src/sample.rs b/src/sample.rs index 300958d..36f45a3 100644 --- a/src/sample.rs +++ b/src/sample.rs @@ -69,8 +69,8 @@ impl Sample<[u8], S> { /// The caller must ensure that the [u8] is actually a T. It is undefined behavior if the underlying data is not a T. pub unsafe fn try_as(&self) -> Option<&T> { let chunk_header = self.data.chunk_header(); - let payload_size = chunk_header.get_user_payload_size() as usize; - let payload_alignment = chunk_header.get_user_payload_alignment() as usize; + let payload_size = chunk_header.get_user_payload_size(); + let payload_alignment = chunk_header.get_user_payload_alignment(); if payload_size >= std::mem::size_of::() && payload_alignment >= std::mem::align_of::() diff --git a/src/sample_mut.rs b/src/sample_mut.rs index f6b269b..3c6ad2b 100644 --- a/src/sample_mut.rs +++ b/src/sample_mut.rs @@ -122,8 +122,8 @@ impl<'a> SampleMut<'a, [MaybeUninit]> { pub fn try_as_uninit(&mut self) -> Option<&mut MaybeUninit> { unsafe { let chunk_header = self.data.chunk_header(); - let payload_size = chunk_header.get_user_payload_size() as usize; - let payload_alignment = chunk_header.get_user_payload_alignment() as usize; + let payload_size = chunk_header.get_user_payload_size(); + let payload_alignment = chunk_header.get_user_payload_alignment(); if payload_size >= std::mem::size_of::() && payload_alignment >= std::mem::align_of::()