From c5b1d0deee4c8112e34cac88098ee1ba8d846ac9 Mon Sep 17 00:00:00 2001 From: Alfredo Garcia Date: Mon, 22 Mar 2021 12:53:17 -0300 Subject: [PATCH] move consts to start of the function --- zebra-network/src/protocol/external/codec.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/zebra-network/src/protocol/external/codec.rs b/zebra-network/src/protocol/external/codec.rs index 9b14438d8..519869f84 100644 --- a/zebra-network/src/protocol/external/codec.rs +++ b/zebra-network/src/protocol/external/codec.rs @@ -588,15 +588,15 @@ impl Codec { } fn read_filterload(&self, mut reader: R, body_len: usize) -> Result { + const MAX_FILTERLOAD_LENGTH: usize = 36000; + const FILTERLOAD_REMAINDER_LENGTH: usize = 4 + 4 + 1; + if !(FILTERLOAD_REMAINDER_LENGTH <= body_len && body_len <= FILTERLOAD_REMAINDER_LENGTH + MAX_FILTERLOAD_LENGTH) { return Err(Error::Parse("Invalid filterload message body length.")); } - const MAX_FILTERLOAD_LENGTH: usize = 36000; - const FILTERLOAD_REMAINDER_LENGTH: usize = 4 + 4 + 1; - let filter_length: usize = body_len - FILTERLOAD_REMAINDER_LENGTH; let mut filter_bytes = vec![0; filter_length];