From 0599a7fa9fce1bbd4a543c6f5bb63f911a676872 Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Tue, 13 Jun 2023 13:28:47 -0700 Subject: [PATCH] mesh: Fix build error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes the following error: In function ‘get_composition’, inlined from ‘cfg_srv_pkt’ at mesh/cfgmod-server.c:801:8: mesh/cfgmod-server.c:758:9: error: ‘comp’ may be used uninitialized [-Werror=maybe-uninitialized] 758 | memcpy(buf, comp, len); | ^~~~~~~~~~~~~~~~~~~~~~ mesh/cfgmod-server.c: In function ‘cfg_srv_pkt’: mesh/cfgmod-server.c:739:24: note: ‘comp’ was declared here 739 | const uint8_t *comp; | ^~~~ --- mesh/cfgmod-server.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index 3d7efc44b..f64566daf 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -736,7 +736,7 @@ static uint16_t cfg_net_tx_msg(struct mesh_node *node, const uint8_t *pkt, static uint16_t get_composition(struct mesh_node *node, uint8_t page, uint8_t *buf) { - const uint8_t *comp; + const uint8_t *comp = NULL; uint16_t len = 0; size_t i; @@ -751,7 +751,7 @@ static uint16_t get_composition(struct mesh_node *node, uint8_t page, break; } - if (!len) + if (!len || !comp) return 0; *buf++ = page; -- 2.47.3