From 35b18cd6879e730f150dd2aacf761a00eeb4615f Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Fri, 25 May 2018 18:10:18 +0200 Subject: ipcpd: Fix false positive incompatible malloc type A malloc was performed with a mgmt_msg type and converted to a uint8_t buffer for serialization, which triggers a false positive warning with the clang static analyzer. Signed-off-by: Dimitri Staessens Signed-off-by: Sander Vrijders --- src/ipcpd/udp/main.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/ipcpd/udp/main.c b/src/ipcpd/udp/main.c index be7491f4..26f993ce 100644 --- a/src/ipcpd/udp/main.c +++ b/src/ipcpd/udp/main.c @@ -236,23 +236,21 @@ static int ipcp_udp_port_alloc_resp(uint32_t dst_ip_addr, uint16_t dst_udp_port, int response) { - uint8_t * buf; struct mgmt_msg * msg; int ret; - buf = malloc(sizeof(*msg)); - if (buf == NULL) + msg = malloc(sizeof(*msg)); + if (msg == NULL) return -1; - msg = (struct mgmt_msg *) buf; msg->code = FLOW_REPLY; msg->src_udp_port = src_udp_port; msg->dst_udp_port = dst_udp_port; msg->response = response; - ret = send_shim_udp_msg(buf, sizeof(*msg), dst_ip_addr); + ret = send_shim_udp_msg((uint8_t *) msg, sizeof(*msg), dst_ip_addr); - free(buf); + free(msg); return ret; } -- cgit v1.2.3