mirror of
https://github.com/aljazceru/lightning.git
synced 2026-02-07 07:04:25 +01:00
common/amount: fix OpenBSD compile warning.
```
cc common/amount.c
common/amount.c:306:15: error: implicit conversion from 'unsigned long long' to
'double' changes value from 18446744073709551615 to 18446744073709551616
[-Werror,-Wimplicit-int-float-conversion]
if (scaled > UINT64_MAX)
~ ^~~~~~~~~~
/usr/include/sys/stdint.h:123:21: note: expanded from macro 'UINT64_MAX'
^~~~~~~~~~~~~~~~~~~~~
1 error generated.
gmake: *** [Makefile:254: common/amount.o] Error 1
bsd$
```
Fixes: #4044
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -303,7 +303,9 @@ WARN_UNUSED_RESULT bool amount_msat_scale(struct amount_msat *val,
|
||||
{
|
||||
double scaled = sat.millisatoshis * scale;
|
||||
|
||||
if (scaled > UINT64_MAX)
|
||||
/* If mantissa is < 64 bits, a naive "if (scaled >
|
||||
* UINT64_MAX)" doesn't work. Stick to powers of 2. */
|
||||
if (scaled >= (double)((u64)1 << 63) * 2)
|
||||
return false;
|
||||
val->millisatoshis = scaled;
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user