From a57d365e35e23db6528c96517feb25261d10097b Mon Sep 17 00:00:00 2001 From: Damian Krolik Date: Thu, 10 Oct 2024 14:20:35 +0200 Subject: [PATCH] nrf_rpc: fix build error for C++ In C++, conversion from a function pointer to void* is either undefined (prior to C++11) or not implicit. Replace the cast from a function pointer to (void*) with a cast to (uintptr_t) to fix build errors when including nrf_rpc.h in C++ applications. Signed-off-by: Damian Krolik --- nrf_rpc/include/nrf_rpc.h | 16 ++++++++-------- nrf_rpc/nrf_rpc.c | 10 +++++----- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/nrf_rpc/include/nrf_rpc.h b/nrf_rpc/include/nrf_rpc.h index 8fd77a84af..07e861b87a 100644 --- a/nrf_rpc/include/nrf_rpc.h +++ b/nrf_rpc/include/nrf_rpc.h @@ -520,10 +520,10 @@ static inline int nrf_rpc_cmd(const struct nrf_rpc_group *group, uint8_t cmd, nrf_rpc_handler_t handler, void *handler_data) { int nrf_rpc_cmd_common(const struct nrf_rpc_group *group, uint32_t cmd, - uint8_t *packet, size_t len, void *ptr1, + uint8_t *packet, size_t len, uintptr_t ptr1, void *ptr2); - return nrf_rpc_cmd_common(group, cmd, packet, len, handler, + return nrf_rpc_cmd_common(group, cmd, packet, len, (uintptr_t)handler, handler_data); } @@ -532,10 +532,10 @@ static inline int nrf_rpc_cmd_rsp(const struct nrf_rpc_group *group, const uint8_t **rsp_packet, size_t *rsp_len) { int nrf_rpc_cmd_common(const struct nrf_rpc_group *group, uint32_t cmd, - uint8_t *packet, size_t len, void *ptr1, + uint8_t *packet, size_t len, uintptr_t ptr1, void *ptr2); - return nrf_rpc_cmd_common(group, cmd | 0x10000, packet, len, rsp_packet, + return nrf_rpc_cmd_common(group, cmd | 0x10000, packet, len, (uintptr_t)rsp_packet, rsp_len); } @@ -546,9 +546,9 @@ static inline void nrf_rpc_cmd_no_err(const struct nrf_rpc_group *group, { void nrf_rpc_cmd_common_no_err(const struct nrf_rpc_group *group, uint32_t cmd, uint8_t *packet, - size_t len, void *ptr1, void *ptr2); + size_t len, uintptr_t ptr1, void *ptr2); - nrf_rpc_cmd_common_no_err(group, cmd, packet, len, handler, + nrf_rpc_cmd_common_no_err(group, cmd, packet, len, (uintptr_t)handler, handler_data); } @@ -560,9 +560,9 @@ static inline void nrf_rpc_cmd_rsp_no_err(const struct nrf_rpc_group *group, { void nrf_rpc_cmd_common_no_err(const struct nrf_rpc_group *group, uint32_t cmd, uint8_t *packet, - size_t len, void *ptr1, void *ptr2); + size_t len, uintptr_t ptr1, void *ptr2); - nrf_rpc_cmd_common_no_err(group, cmd | 0x10000, packet, len, rsp_packet, + nrf_rpc_cmd_common_no_err(group, cmd | 0x10000, packet, len, (uintptr_t)rsp_packet, rsp_len); } diff --git a/nrf_rpc/nrf_rpc.c b/nrf_rpc/nrf_rpc.c index f2a97b117a..9c655aa689 100644 --- a/nrf_rpc/nrf_rpc.c +++ b/nrf_rpc/nrf_rpc.c @@ -878,7 +878,7 @@ static void wait_for_response(const struct nrf_rpc_group *group, struct nrf_rpc_ } int nrf_rpc_cmd_common(const struct nrf_rpc_group *group, uint32_t cmd, - uint8_t *packet, size_t len, void *ptr1, void *ptr2) + uint8_t *packet, size_t len, uintptr_t ptr1, void *ptr2) { int err; struct header hdr; @@ -894,16 +894,16 @@ int nrf_rpc_cmd_common(const struct nrf_rpc_group *group, uint32_t cmd, NRF_RPC_ASSERT(group != NULL); NRF_RPC_ASSERT((cmd & 0xFF) != NRF_RPC_ID_UNKNOWN); NRF_RPC_ASSERT(packet_validate(packet)); - NRF_RPC_ASSERT(ptr1 != NULL); + NRF_RPC_ASSERT(ptr1 != 0); if (cmd & 0x10000) { NRF_RPC_ASSERT(ptr2 != NULL); - rsp_packet = ptr1; + rsp_packet = (const uint8_t**)ptr1; rsp_len = ptr2; *rsp_packet = NULL; *rsp_len = 0; } else { - handler = ptr1; + handler = (nrf_rpc_handler_t)ptr1; handler_data = ptr2; } @@ -939,7 +939,7 @@ int nrf_rpc_cmd_common(const struct nrf_rpc_group *group, uint32_t cmd, } void nrf_rpc_cmd_common_no_err(const struct nrf_rpc_group *group, uint32_t cmd, - uint8_t *packet, size_t len, void *ptr1, + uint8_t *packet, size_t len, uintptr_t ptr1, void *ptr2) { int err;