summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSunil Nimmagadda <sunil@nimmagadda.net>2025-09-07 17:37:20 +0530
committerSunil Nimmagadda <sunil@nimmagadda.net>2025-09-07 17:37:20 +0530
commit622e7f3b87427d1857bf2cedb6e81abb48d2ba60 (patch)
treea09dc9b459f40c840a7036af91c0866dd8471d11 /src
parent0a43b0a8be4ef09b19ff8829ed0d23a8c6b2d523 (diff)
Use size_of instead of hard coded numbers.
Diffstat (limited to 'src')
-rw-r--r--src/vrrpv2.rs6
1 files 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<u8> {
- let mut buffer = [0; 1];
+ let mut buffer = [0; size_of::<u8>()];
cursor.read_exact(&mut buffer)?;
Ok(u8::from_be_bytes(buffer))
}
fn read_u16(cursor: &mut Cursor<&[u8]>) -> io::Result<u16> {
- let mut buffer = [0; 2];
+ let mut buffer = [0; size_of::<u16>()];
cursor.read_exact(&mut buffer)?;
Ok(u16::from_be_bytes(buffer))
}
fn read_u32(cursor: &mut Cursor<&[u8]>) -> io::Result<u32> {
- let mut buffer = [0; 4];
+ let mut buffer = [0; size_of::<u32>()];
cursor.read_exact(&mut buffer)?;
Ok(u32::from_be_bytes(buffer))
}