From 622e7f3b87427d1857bf2cedb6e81abb48d2ba60 Mon Sep 17 00:00:00 2001 From: Sunil Nimmagadda Date: Sun, 7 Sep 2025 17:37:20 +0530 Subject: Use size_of instead of hard coded numbers. --- src/vrrpv2.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/vrrpv2.rs b/src/vrrpv2.rs index 63c58c8..7e4a6cd 100644 --- a/src/vrrpv2.rs +++ b/src/vrrpv2.rs @@ -115,19 +115,19 @@ impl VRRPv2 { } fn read_u8(cursor: &mut Cursor<&[u8]>) -> io::Result { - let mut buffer = [0; 1]; + let mut buffer = [0; size_of::()]; cursor.read_exact(&mut buffer)?; Ok(u8::from_be_bytes(buffer)) } fn read_u16(cursor: &mut Cursor<&[u8]>) -> io::Result { - let mut buffer = [0; 2]; + let mut buffer = [0; size_of::()]; cursor.read_exact(&mut buffer)?; Ok(u16::from_be_bytes(buffer)) } fn read_u32(cursor: &mut Cursor<&[u8]>) -> io::Result { - let mut buffer = [0; 4]; + let mut buffer = [0; size_of::()]; cursor.read_exact(&mut buffer)?; Ok(u32::from_be_bytes(buffer)) } -- cgit v1.2.3