In #4556, we updated our generic virtio buffer handling code to describe buffer sizes using u32 instead of usize, since the virtio specification states that lengths of virtio-buffers fit into u32 (and header fields in the virtio protocol describing lengths are typed to be 32 bit integers).
From that work, a small follow up is possible in the vsock module, where we can now also describe lengths of vsock packages using u32 instead of usize. This will allow us to get rid of a few more explicit casts. Particularly, we can do the following changes to function signatures:
VsockConnection::peer_avail_credit can return u32
VsockPacket::buf_size can return u32
VsockPacket::read_at_offset_from should be (&self, &mut T, u32, u32) -> Result<u32, VsockError> (e..g. the conversion to usize should only happen right around the write_volatile_at call
ditto for VsockPacket::write_from_offset_to
Maybe we can even get away with changing the arguments IoVecBuffer[Mut]::{read,write}_volatile_at to u32s
In #4556, we updated our generic virtio buffer handling code to describe buffer sizes using
u32
instead ofusize
, since the virtio specification states that lengths of virtio-buffers fit intou32
(and header fields in the virtio protocol describing lengths are typed to be 32 bit integers).From that work, a small follow up is possible in the vsock module, where we can now also describe lengths of vsock packages using
u32
instead ofusize
. This will allow us to get rid of a few more explicit casts. Particularly, we can do the following changes to function signatures:VsockConnection::peer_avail_credit
can returnu32
VsockPacket::buf_size
can returnu32
VsockPacket::read_at_offset_from
should be(&self, &mut T, u32, u32) -> Result<u32, VsockError>
(e..g. the conversion to usize should only happen right around thewrite_volatile_at
callVsockPacket::write_from_offset_to
Maybe we can even get away with changing the argumentsIoVecBuffer[Mut]::{read,write}_volatile_at
tou32
s