diff mbox series

[OpenWrt-Devel,ubus,05/16] libubus: fix incompatible pointer types assigment

Message ID 20191219221125.22646-6-ynezz@true.cz
State Accepted
Delegated to: Petr Štetiar
Headers show
Series GitLab CI, tests, fuzzing, fixes and improvements | expand

Commit Message

Petr Štetiar Dec. 19, 2019, 10:11 p.m. UTC
Fixes following error reported by clang-9 analyzer:

 libubus.c:286:19: error: incompatible pointer types assigning to 'struct blob_attr *' from 'char *' [-Werror,-Wincompatible-pointer-types]
         ctx->msgbuf.data = (char *) calloc(UBUS_MSG_CHUNK_SIZE, sizeof(char));

Result of 'calloc' is converted to a pointer of type 'struct blob_attr',
which is incompatible with sizeof operand type 'char'.

Signed-off-by: Petr Štetiar <ynezz@true.cz>
---
 libubus.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/libubus.c b/libubus.c
index 260e40f2f44b..846ae83bcc12 100644
--- a/libubus.c
+++ b/libubus.c
@@ -283,7 +283,7 @@  int ubus_connect_ctx(struct ubus_context *ctx, const char *path)
 	ctx->connection_lost = ubus_default_connection_lost;
 	ctx->pending_timer.cb = ubus_process_pending_msg;
 
-	ctx->msgbuf.data = calloc(UBUS_MSG_CHUNK_SIZE, sizeof(char));
+	ctx->msgbuf.data = calloc(1, UBUS_MSG_CHUNK_SIZE);
 	if (!ctx->msgbuf.data)
 		return -1;
 	ctx->msgbuf_data_len = UBUS_MSG_CHUNK_SIZE;