From 9aaf2fe8d417479e1aac5f186491f55a159ba584 Mon Sep 17 00:00:00 2001 From: William Casarin Date: Sat, 2 Mar 2019 10:40:44 -0800 Subject: [PATCH] build: fix uninitialized variable error on gcc 7.4.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit *best is checked for null before the comparison against the uninitialized variable ever happens, so this isn't a real issue. Initialize it to zero so that we don't fail to compile on certain gcc versions. plugins/pay.c: In function ‘add_shadow_route’: plugins/pay.c:644:18: error: ‘sample’ may be used uninitialized in this function if (!best || v > sample) { ~~^~~~~~~~ Signed-off-by: William Casarin --- plugins/pay.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/pay.c b/plugins/pay.c index f85dbc6f2..005767b58 100644 --- a/plugins/pay.c +++ b/plugins/pay.c @@ -658,7 +658,7 @@ static struct command_result *add_shadow_route(struct command *cmd, const jsmntok_t *channels = json_get_member(buf, result, "channels"); const jsmntok_t *chan, *best = NULL; size_t i; - u64 sample; + u64 sample = 0; u32 cltv, best_cltv; json_for_each_arr(i, chan, channels) {