From 6b79b2aaa513d0494a0a4c8c3d3b85bf0649d5dc Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Tue, 3 Oct 2023 17:05:55 +0300 Subject: [PATCH] encoding.leb128: fix `v -cstrict -cc gcc-11 examples/wasm_codegen/bf_compiler.v` --- vlib/encoding/leb128/leb128.v | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/vlib/encoding/leb128/leb128.v b/vlib/encoding/leb128/leb128.v index 0c679d0bb096ca..b5acd5ac19270d 100644 --- a/vlib/encoding/leb128/leb128.v +++ b/vlib/encoding/leb128/leb128.v @@ -68,19 +68,19 @@ pub fn encode_u32(value u32) []u8 { // decode_i32 decodes an i32 and returns the number of bytes used from the given leb128 encoded array `value` pub fn decode_i32(value []u8) (i32, int) { - mut result := int(0) + mut result := u32(0) mut shift := 0 for b in value { - result |= b & 0x7f << shift + result |= u32(b & 0x7f) << shift shift += 7 if b & 0x80 == 0 { if shift < 32 && b & 0x40 != 0 { - result |= ~0 << shift + result |= u32(~0) << shift } break } } - return result, shift / 7 + return int(result), shift / 7 } // decode_i64 decodes an i64 and returns the number of bytes used from the given leb128 encoded array `value`