From 6730e16439ad7f8c1e033fd4238cf9ddd177d9be Mon Sep 17 00:00:00 2001 From: tersec Date: Tue, 4 Jul 2023 14:29:26 +0000 Subject: [PATCH] replace integer cast with conversion (#5160) --- ncli/e2store.nim | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/ncli/e2store.nim b/ncli/e2store.nim index 2e96f3c71..3047b1dd8 100644 --- a/ncli/e2store.nim +++ b/ncli/e2store.nim @@ -1,3 +1,10 @@ +# beacon_chain +# Copyright (c) 2021-2023 Status Research & Development GmbH +# Licensed and distributed under either of +# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). +# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). +# at your option. This file may not be copied, modified, or distributed except according to those terms. + {.push raises: [].} import @@ -148,9 +155,8 @@ proc readHeader(f: IoHandle): Result[Header, string] = typ: Type discard typ.copyFrom(buf) - # Cast safe because we had only 4 bytes of length data - let - len = cast[int64](uint32.fromBytesLE(buf.toOpenArray(2, 5))) + # Conversion safe because we had only 4 bytes of length data + let len = (uint32.fromBytesLE(buf.toOpenArray(2, 5))).int64 # No point reading these.. if len > int.high(): return err("header length exceeds int.high")