From 72486262357aef3a5eaa4652e6288328c381ea7f Mon Sep 17 00:00:00 2001 From: Calvin Rose Date: Sat, 24 Jun 2023 10:56:45 -0500 Subject: [PATCH] Quiet some build warnings. --- src/core/specials.c | 2 ++ src/core/value.c | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/core/specials.c b/src/core/specials.c index 4f2b9740..03cb0e26 100644 --- a/src/core/specials.c +++ b/src/core/specials.c @@ -358,6 +358,8 @@ SlotHeadPair *dohead_destructure(JanetCompiler *c, SlotHeadPair *into, JanetFopt if (has_drop && can_destructure_lhs && rhs_is_indexed) { /* Code is of the form (def [a b] [1 2]), avoid the allocation of two tuples */ JanetView view_lhs, view_rhs; + view_rhs.len = 0; + view_lhs.len = 0; janet_indexed_view(lhs, &view_lhs.items, &view_lhs.len); janet_indexed_view(rhs, &view_rhs.items, &view_rhs.len); int found_amp = 0; diff --git a/src/core/value.c b/src/core/value.c index 37ca4041..8a2c3bfa 100644 --- a/src/core/value.c +++ b/src/core/value.c @@ -698,7 +698,8 @@ Janet janet_lengthv(Janet x) { const JanetAbstractType *type = janet_abstract_type(abst); if (type->length != NULL) { size_t len = type->length(abst, janet_abstract_size(abst)); - if ((uint64_t) len <= (uint64_t) JANET_INTMAX_INT64) { + /* If len is always less then double, we can never overflow */ + if (((int64_t) SIZE_MAX <= JANET_INTMAX_INT64) || (len < (size_t) JANET_INTMAX_INT64)) { return janet_wrap_number((double) len); } else { janet_panicf("integer length %u too large", len);