From: Luiz Augusto von Dentz Date: Tue, 13 Jun 2023 20:28:47 +0000 (-0700) Subject: mesh: Fix build error X-Git-Tag: accepted/tizen/unified/20240117.163238~170 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=43a01201dfaab92ffeddd119cc79f3de7b4f8424;p=platform%2Fupstream%2Fbluez.git mesh: Fix build error 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; | ^~~~ --- diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index 3d7efc4..f64566d 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;