Berry fix warnings when running unit tests (#24859)

This commit is contained in:
s-hadinger
2026-06-26 15:52:27 +02:00
committed by GitHub
parent 39ad0f57a4
commit e352266405
4 changed files with 8 additions and 7 deletions
+1 -1
View File
@@ -429,7 +429,7 @@ static bint scan_hexadecimal(blexer *lexer)
bint res = 0;
int dig, num = 0;
while ((dig = be_char2hex(lgetc(lexer))) >= 0) {
res = ((bint)res << 4) + dig;
res = (bint)(((buint)res << 4) + (buint)dig);
next(lexer);
++num;
}
+1 -1
View File
@@ -387,7 +387,7 @@ BERRY_API bint be_str2int(const char *str, const char **endstr)
/* hex literal */
str += 2; /* skip 0x or 0X */
while ((c = be_char2hex(*str++)) >= 0) {
sum = sum * 16 + c;
sum = (bint)((buint)sum * 16 + (buint)c);
}
if (endstr) {
*endstr = str - 1;
+1
View File
@@ -50,6 +50,7 @@ extern "C" {
typedef uint8_t bbyte; /**< bbyte */
typedef BE_INTEGER bint; /**< bint */
typedef unsigned BE_INTEGER buint; /**< buint (unsigned bint, for well-defined wrap-around arithmetic) */
#if BE_USE_SINGLE_FLOAT != 0
typedef float breal; /**< breal */
@@ -28,7 +28,7 @@
static void int64_toa(int64_t num, uint8_t* str) {
uint64_t sum = num;
if (num < 0) {
sum = -num;
sum = -(uint64_t)num; /* negate in unsigned domain to avoid UB on INT64_MIN */
str[0] = '-';
str++;
}
@@ -226,7 +226,7 @@ static int int64_fromu32(bvm *vm) {
int argc = be_top(vm);
uint32_t low = (uint32_t)be_toint(vm, 1);
uint32_t high = (argc > 1) ? (uint32_t)be_toint(vm, 2) : 0;
int64_t val = (int64_t)low | (((int64_t)high) << 32);
int64_t val = (int64_t)((uint64_t)low | ((uint64_t)high << 32));
push_int64_instance(vm, val);
be_return(vm);
}
@@ -347,7 +347,7 @@ static int int64_mod(bvm *vm) {
static int int64_shiftleft(bvm *vm) {
int64_t *i64 = self_get_p(vm);
int32_t j32 = be_toint(vm, 2) & 63;
push_int64_instance(vm, *i64 << j32);
push_int64_instance(vm, (int64_t)((uint64_t)*i64 << j32));
be_return(vm);
}