From dbd5802d3121cd12b7ac7c1f9cd8282ec9cf75c9 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Sat, 12 Sep 2020 14:54:47 +0930 Subject: [PATCH 1/2] lightningd: don't declare local vars stdin and stdout. OpenBSD uses macros for these, and gets upset. Fixes: #4044 Signed-off-by: Rusty Russell --- lightningd/plugin.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lightningd/plugin.c b/lightningd/plugin.c index 43ecf48aa8dd..9220d77f357f 100644 --- a/lightningd/plugin.c +++ b/lightningd/plugin.c @@ -1295,7 +1295,7 @@ void plugins_add_default_dir(struct plugins *plugins) const char *plugin_send_getmanifest(struct plugin *p) { char **cmd; - int stdin, stdout; + int stdinfd, stdoutfd; struct jsonrpc_request *req; bool debug = false; @@ -1308,7 +1308,7 @@ const char *plugin_send_getmanifest(struct plugin *p) cmd[0] = p->cmd; if (debug) cmd[1] = "--debugger"; - p->pid = pipecmdarr(&stdin, &stdout, &pipecmd_preserve, cmd); + p->pid = pipecmdarr(&stdinfd, &stdoutfd, &pipecmd_preserve, cmd); if (p->pid == -1) return tal_fmt(p, "opening pipe: %s", strerror(errno)); @@ -1319,8 +1319,8 @@ const char *plugin_send_getmanifest(struct plugin *p) /* Create two connections, one read-only on top of p->stdout, and one * write-only on p->stdin */ - p->stdout_conn = io_new_conn(p, stdout, plugin_stdout_conn_init, p); - p->stdin_conn = io_new_conn(p, stdin, plugin_stdin_conn_init, p); + p->stdout_conn = io_new_conn(p, stdoutfd, plugin_stdout_conn_init, p); + p->stdin_conn = io_new_conn(p, stdinfd, plugin_stdin_conn_init, p); req = jsonrpc_request_start(p, "getmanifest", p->log, plugin_manifest_cb, p); /* Adding allow-deprecated-apis is part of the deprecation cycle! */ From 096976e0e416425bdf1ce27eb5cbcdf79a2142b9 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Sun, 13 Sep 2020 15:21:57 +0930 Subject: [PATCH 2/2] 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 --- common/amount.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/common/amount.c b/common/amount.c index bf9c74d17959..7c1f57d50a1a 100644 --- a/common/amount.c +++ b/common/amount.c @@ -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;