replace integer cast with conversion (#5160)
This commit is contained in:
parent
ad3b2fb5ed
commit
6730e16439
|
@ -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: [].}
|
{.push raises: [].}
|
||||||
|
|
||||||
import
|
import
|
||||||
|
@ -148,9 +155,8 @@ proc readHeader(f: IoHandle): Result[Header, string] =
|
||||||
typ: Type
|
typ: Type
|
||||||
discard typ.copyFrom(buf)
|
discard typ.copyFrom(buf)
|
||||||
|
|
||||||
# Cast safe because we had only 4 bytes of length data
|
# Conversion safe because we had only 4 bytes of length data
|
||||||
let
|
let len = (uint32.fromBytesLE(buf.toOpenArray(2, 5))).int64
|
||||||
len = cast[int64](uint32.fromBytesLE(buf.toOpenArray(2, 5)))
|
|
||||||
|
|
||||||
# No point reading these..
|
# No point reading these..
|
||||||
if len > int.high(): return err("header length exceeds int.high")
|
if len > int.high(): return err("header length exceeds int.high")
|
||||||
|
|
Loading…
Reference in New Issue