From 2d7f26846590116c3a80711ae3aed81dfd94a684 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 8 May 2025 12:20:47 +0930 Subject: [PATCH] lightningd: don't allocate to print node_id for logging. Signed-off-by: Rusty Russell --- lightningd/log.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lightningd/log.c b/lightningd/log.c index 09a510e19..8828f6996 100644 --- a/lightningd/log.c +++ b/lightningd/log.c @@ -207,7 +207,7 @@ static void log_to_files(const char *log_prefix, struct log_file **log_files) { char tstamp[sizeof("YYYY-mm-ddTHH:MM:SS.nnnZ ")]; - char *entry, *nodestr; + char *entry, nodestr[hex_str_size(PUBKEY_CMPR_LEN)]; bool filtered; if (print_timestamps) { @@ -218,9 +218,10 @@ static void log_to_files(const char *log_prefix, tstamp[0] = '\0'; if (node_id) - nodestr = fmt_node_id(tmpctx, node_id); + hex_encode(node_id->k, sizeof(node_id->k), + nodestr, sizeof(nodestr)); else - nodestr = ""; + nodestr[0] = '\0'; if (level == LOG_IO_IN || level == LOG_IO_OUT) { const char *dir = level == LOG_IO_IN ? "[IN]" : "[OUT]"; char *hex = tal_hexstr(NULL, io, io_len);