Skip to content

Commit a57d365

Browse files
committed
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 <[email protected]>
1 parent 62920b9 commit a57d365

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

nrf_rpc/include/nrf_rpc.h

+8-8
Original file line numberDiff line numberDiff line change
@@ -520,10 +520,10 @@ static inline int nrf_rpc_cmd(const struct nrf_rpc_group *group, uint8_t cmd,
520520
nrf_rpc_handler_t handler, void *handler_data)
521521
{
522522
int nrf_rpc_cmd_common(const struct nrf_rpc_group *group, uint32_t cmd,
523-
uint8_t *packet, size_t len, void *ptr1,
523+
uint8_t *packet, size_t len, uintptr_t ptr1,
524524
void *ptr2);
525525

526-
return nrf_rpc_cmd_common(group, cmd, packet, len, handler,
526+
return nrf_rpc_cmd_common(group, cmd, packet, len, (uintptr_t)handler,
527527
handler_data);
528528
}
529529

@@ -532,10 +532,10 @@ static inline int nrf_rpc_cmd_rsp(const struct nrf_rpc_group *group,
532532
const uint8_t **rsp_packet, size_t *rsp_len)
533533
{
534534
int nrf_rpc_cmd_common(const struct nrf_rpc_group *group, uint32_t cmd,
535-
uint8_t *packet, size_t len, void *ptr1,
535+
uint8_t *packet, size_t len, uintptr_t ptr1,
536536
void *ptr2);
537537

538-
return nrf_rpc_cmd_common(group, cmd | 0x10000, packet, len, rsp_packet,
538+
return nrf_rpc_cmd_common(group, cmd | 0x10000, packet, len, (uintptr_t)rsp_packet,
539539
rsp_len);
540540
}
541541

@@ -546,9 +546,9 @@ static inline void nrf_rpc_cmd_no_err(const struct nrf_rpc_group *group,
546546
{
547547
void nrf_rpc_cmd_common_no_err(const struct nrf_rpc_group *group,
548548
uint32_t cmd, uint8_t *packet,
549-
size_t len, void *ptr1, void *ptr2);
549+
size_t len, uintptr_t ptr1, void *ptr2);
550550

551-
nrf_rpc_cmd_common_no_err(group, cmd, packet, len, handler,
551+
nrf_rpc_cmd_common_no_err(group, cmd, packet, len, (uintptr_t)handler,
552552
handler_data);
553553
}
554554

@@ -560,9 +560,9 @@ static inline void nrf_rpc_cmd_rsp_no_err(const struct nrf_rpc_group *group,
560560
{
561561
void nrf_rpc_cmd_common_no_err(const struct nrf_rpc_group *group,
562562
uint32_t cmd, uint8_t *packet,
563-
size_t len, void *ptr1, void *ptr2);
563+
size_t len, uintptr_t ptr1, void *ptr2);
564564

565-
nrf_rpc_cmd_common_no_err(group, cmd | 0x10000, packet, len, rsp_packet,
565+
nrf_rpc_cmd_common_no_err(group, cmd | 0x10000, packet, len, (uintptr_t)rsp_packet,
566566
rsp_len);
567567
}
568568

nrf_rpc/nrf_rpc.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,7 @@ static void wait_for_response(const struct nrf_rpc_group *group, struct nrf_rpc_
878878
}
879879

880880
int nrf_rpc_cmd_common(const struct nrf_rpc_group *group, uint32_t cmd,
881-
uint8_t *packet, size_t len, void *ptr1, void *ptr2)
881+
uint8_t *packet, size_t len, uintptr_t ptr1, void *ptr2)
882882
{
883883
int err;
884884
struct header hdr;
@@ -894,16 +894,16 @@ int nrf_rpc_cmd_common(const struct nrf_rpc_group *group, uint32_t cmd,
894894
NRF_RPC_ASSERT(group != NULL);
895895
NRF_RPC_ASSERT((cmd & 0xFF) != NRF_RPC_ID_UNKNOWN);
896896
NRF_RPC_ASSERT(packet_validate(packet));
897-
NRF_RPC_ASSERT(ptr1 != NULL);
897+
NRF_RPC_ASSERT(ptr1 != 0);
898898

899899
if (cmd & 0x10000) {
900900
NRF_RPC_ASSERT(ptr2 != NULL);
901-
rsp_packet = ptr1;
901+
rsp_packet = (const uint8_t**)ptr1;
902902
rsp_len = ptr2;
903903
*rsp_packet = NULL;
904904
*rsp_len = 0;
905905
} else {
906-
handler = ptr1;
906+
handler = (nrf_rpc_handler_t)ptr1;
907907
handler_data = ptr2;
908908
}
909909

@@ -939,7 +939,7 @@ int nrf_rpc_cmd_common(const struct nrf_rpc_group *group, uint32_t cmd,
939939
}
940940

941941
void nrf_rpc_cmd_common_no_err(const struct nrf_rpc_group *group, uint32_t cmd,
942-
uint8_t *packet, size_t len, void *ptr1,
942+
uint8_t *packet, size_t len, uintptr_t ptr1,
943943
void *ptr2)
944944
{
945945
int err;

0 commit comments

Comments
 (0)