damus

nostr ios client
git clone git://jb55.com/damus
Log | Files | Refs | README | LICENSE

commit b65d9a49ffc1fb85266584ff9468350e55f68c47
parent 9666180db5da4292eaf722ec2dc48ebda18714e5
Author: William Casarin <jb55@jb55.com>
Date:   Sun,  1 Jan 2023 10:30:40 -0800

c: silence warnings

Diffstat:
Mdamus-c/amount.c | 4++--
Mdamus-c/bolt11.c | 2+-
Mdamus-c/hash_u5.c | 4++--
Mdamus-c/overflows.h | 2+-
4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/damus-c/amount.c b/damus-c/amount.c @@ -151,7 +151,7 @@ static bool from_numbers(u64 *res, return false; if (!from_number(&p1, s1, len1, tens_factor) - || !from_number(&p2, s2, len2, tens_factor - len2)) + || !from_number(&p2, s2, len2, tens_factor - (int)len2)) return false; if (add_overflows_u64(p1, p2)) @@ -453,7 +453,7 @@ bool amount_msat_to_u32(struct amount_msat msat, u32 *millisatoshis) { if (amount_msat_greater_eq(msat, AMOUNT_MSAT(0x100000000))) return false; - *millisatoshis = msat.millisatoshis; + *millisatoshis = (u32)msat.millisatoshis; return true; } diff --git a/damus-c/bolt11.c b/damus-c/bolt11.c @@ -297,7 +297,7 @@ static char *decode_c(struct bolt11 *b11, if (!pull_uint(hu5, data, data_len, &c, data_length * 5)) return tal_fmt(b11, "c: length %zu chars is excessive", *data_len); - b11->min_final_cltv_expiry = c; + b11->min_final_cltv_expiry = (u32)c; /* Can overflow, since c is 64 bits but value must be < 32 bits */ if (b11->min_final_cltv_expiry != c) return tal_fmt(b11, "c: %"PRIu64" is too large", c); diff --git a/damus-c/hash_u5.c b/damus-c/hash_u5.c @@ -30,7 +30,7 @@ void hash_u5(struct hash_u5 *hu5, const u8 *u5, size_t len) u5++; if (hu5->num_bits >= 32) { - be32 be32 = cpu_to_be32(hu5->buf >> (hu5->num_bits-32)); + be32 be32 = cpu_to_be32((u32)(hu5->buf >> (hu5->num_bits-32))); sha256_update(&hu5->hash, &be32, sizeof(be32)); hu5->num_bits -= 32; } @@ -40,7 +40,7 @@ void hash_u5(struct hash_u5 *hu5, const u8 *u5, size_t len) void hash_u5_done(struct hash_u5 *hu5, struct sha256 *res) { if (hu5->num_bits) { - be32 be32 = cpu_to_be32(hu5->buf << (32 - hu5->num_bits)); + be32 be32 = cpu_to_be32((u32)(hu5->buf << (32 - hu5->num_bits))); sha256_update(&hu5->hash, &be32, (hu5->num_bits + 7) / 8); } diff --git a/damus-c/overflows.h b/damus-c/overflows.h @@ -37,7 +37,7 @@ static inline bool assign_overflow_u16(u16 *dst, uint64_t v) static inline bool assign_overflow_u32(u32 *dst, uint64_t v) { - *dst = v; + *dst = (u32)v; return *dst == v; } #endif /* LIGHTNING_COMMON_OVERFLOWS_H */