Browse Source

c: silence warnings

post-button-style
William Casarin 2 years ago
parent
commit
b65d9a49ff
  1. 4
      damus-c/amount.c
  2. 2
      damus-c/bolt11.c
  3. 4
      damus-c/hash_u5.c
  4. 2
      damus-c/overflows.h

4
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;
}

2
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);

4
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);
}

2
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 */

Loading…
Cancel
Save