Skip to content

Commit e34e7c9

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 1cdbd26 commit e34e7c9

File tree

2 files changed

+54
-68
lines changed

2 files changed

+54
-68
lines changed

nrf_rpc/include/nrf_rpc.h

+9-68
Original file line numberDiff line numberDiff line change
@@ -372,9 +372,8 @@ int nrf_rpc_init(nrf_rpc_err_handler_t err_handler);
372372
* @return 0 on success or negative error code if a transport layer
373373
* reported a sending error.
374374
*/
375-
static inline int nrf_rpc_cmd(const struct nrf_rpc_group *group, uint8_t cmd,
376-
uint8_t *packet, size_t len,
377-
nrf_rpc_handler_t handler, void *handler_data);
375+
int nrf_rpc_cmd(const struct nrf_rpc_group *group, uint8_t cmd, uint8_t *packet,
376+
size_t len, nrf_rpc_handler_t handler, void *handler_data);
378377

379378
/** @brief Send a command and get response as an output parameter.
380379
*
@@ -394,9 +393,8 @@ static inline int nrf_rpc_cmd(const struct nrf_rpc_group *group, uint8_t cmd,
394393
* @return 0 on success or negative error code if a transport
395394
* layer reported a sending error.
396395
*/
397-
static inline int nrf_rpc_cmd_rsp(const struct nrf_rpc_group *group,
398-
uint8_t cmd, uint8_t *packet, size_t len,
399-
const uint8_t **rsp_packet, size_t *rsp_len);
396+
int nrf_rpc_cmd_rsp(const struct nrf_rpc_group *group, uint8_t cmd, uint8_t *packet,
397+
size_t len, const uint8_t **rsp_packet, size_t *rsp_len);
400398

401399
/** @brief Send a command, provide callback to handle response and pass any
402400
* error to an error handler.
@@ -415,10 +413,8 @@ static inline int nrf_rpc_cmd_rsp(const struct nrf_rpc_group *group,
415413
* undefined if the handler will be called.
416414
* @param handler_data Opaque pointer that will be passed to `handler`.
417415
*/
418-
static inline void nrf_rpc_cmd_no_err(const struct nrf_rpc_group *group,
419-
uint8_t cmd, uint8_t *packet, size_t len,
420-
nrf_rpc_handler_t handler,
421-
void *handler_data);
416+
void nrf_rpc_cmd_no_err(const struct nrf_rpc_group *group, uint8_t cmd, uint8_t *packet,
417+
size_t len, nrf_rpc_handler_t handler, void *handler_data);
422418

423419
/** @brief Send a command, get response as an output parameter and pass any
424420
* error to an error handler.
@@ -434,11 +430,9 @@ static inline void nrf_rpc_cmd_no_err(const struct nrf_rpc_group *group,
434430
* @param[out] rsp_packet Packet containing the response or NULL on error.
435431
* @param[out] rsp_len Length of `rsp_packet`.
436432
*/
437-
static inline void nrf_rpc_cmd_rsp_no_err(const struct nrf_rpc_group *group,
438-
uint8_t cmd, uint8_t *packet,
439-
size_t len,
440-
const uint8_t **rsp_packet,
441-
size_t *rsp_len);
433+
void nrf_rpc_cmd_rsp_no_err(const struct nrf_rpc_group *group, uint8_t cmd,
434+
uint8_t *packet, size_t len, const uint8_t **rsp_packet,
435+
size_t *rsp_len);
442436

443437
/** @brief Send an event.
444438
*
@@ -523,59 +517,6 @@ void nrf_rpc_err(int code, enum nrf_rpc_err_src src,
523517
const struct nrf_rpc_group *group, uint8_t id,
524518
uint8_t packet_type);
525519

526-
/* Inline definitions. */
527-
528-
static inline int nrf_rpc_cmd(const struct nrf_rpc_group *group, uint8_t cmd,
529-
uint8_t *packet, size_t len,
530-
nrf_rpc_handler_t handler, void *handler_data)
531-
{
532-
int nrf_rpc_cmd_common(const struct nrf_rpc_group *group, uint32_t cmd,
533-
uint8_t *packet, size_t len, void *ptr1,
534-
void *ptr2);
535-
536-
return nrf_rpc_cmd_common(group, cmd, packet, len, handler,
537-
handler_data);
538-
}
539-
540-
static inline int nrf_rpc_cmd_rsp(const struct nrf_rpc_group *group,
541-
uint8_t cmd, uint8_t *packet, size_t len,
542-
const uint8_t **rsp_packet, size_t *rsp_len)
543-
{
544-
int nrf_rpc_cmd_common(const struct nrf_rpc_group *group, uint32_t cmd,
545-
uint8_t *packet, size_t len, void *ptr1,
546-
void *ptr2);
547-
548-
return nrf_rpc_cmd_common(group, cmd | 0x10000, packet, len, rsp_packet,
549-
rsp_len);
550-
}
551-
552-
static inline void nrf_rpc_cmd_no_err(const struct nrf_rpc_group *group,
553-
uint8_t cmd, uint8_t *packet, size_t len,
554-
nrf_rpc_handler_t handler,
555-
void *handler_data)
556-
{
557-
void nrf_rpc_cmd_common_no_err(const struct nrf_rpc_group *group,
558-
uint32_t cmd, uint8_t *packet,
559-
size_t len, void *ptr1, void *ptr2);
560-
561-
nrf_rpc_cmd_common_no_err(group, cmd, packet, len, handler,
562-
handler_data);
563-
}
564-
565-
static inline void nrf_rpc_cmd_rsp_no_err(const struct nrf_rpc_group *group,
566-
uint8_t cmd, uint8_t *packet,
567-
size_t len,
568-
const uint8_t **rsp_packet,
569-
size_t *rsp_len)
570-
{
571-
void nrf_rpc_cmd_common_no_err(const struct nrf_rpc_group *group,
572-
uint32_t cmd, uint8_t *packet,
573-
size_t len, void *ptr1, void *ptr2);
574-
575-
nrf_rpc_cmd_common_no_err(group, cmd | 0x10000, packet, len, rsp_packet,
576-
rsp_len);
577-
}
578-
579520
/** @brief Allocates buffer for a packet.
580521
*
581522
* Memory is automatically deallocated after packet sending. If not, @ref nrf_rpc_free_tx_buf

nrf_rpc/nrf_rpc.c

+45
Original file line numberDiff line numberDiff line change
@@ -1163,6 +1163,51 @@ int nrf_rpc_init(nrf_rpc_err_handler_t err_handler)
11631163
return err;
11641164
}
11651165

1166+
int nrf_rpc_cmd(const struct nrf_rpc_group *group, uint8_t cmd, uint8_t *packet,
1167+
size_t len, nrf_rpc_handler_t handler, void *handler_data)
1168+
{
1169+
int nrf_rpc_cmd_common(const struct nrf_rpc_group *group, uint32_t cmd,
1170+
uint8_t *packet, size_t len, void *ptr1,
1171+
void *ptr2);
1172+
1173+
return nrf_rpc_cmd_common(group, cmd, packet, len, handler,
1174+
handler_data);
1175+
}
1176+
1177+
int nrf_rpc_cmd_rsp(const struct nrf_rpc_group *group, uint8_t cmd, uint8_t *packet,
1178+
size_t len, const uint8_t **rsp_packet, size_t *rsp_len)
1179+
{
1180+
int nrf_rpc_cmd_common(const struct nrf_rpc_group *group, uint32_t cmd,
1181+
uint8_t *packet, size_t len, void *ptr1,
1182+
void *ptr2);
1183+
1184+
return nrf_rpc_cmd_common(group, cmd | 0x10000, packet, len, rsp_packet,
1185+
rsp_len);
1186+
}
1187+
1188+
void nrf_rpc_cmd_no_err(const struct nrf_rpc_group *group, uint8_t cmd, uint8_t *packet,
1189+
size_t len, nrf_rpc_handler_t handler, void *handler_data)
1190+
{
1191+
void nrf_rpc_cmd_common_no_err(const struct nrf_rpc_group *group,
1192+
uint32_t cmd, uint8_t *packet,
1193+
size_t len, void *ptr1, void *ptr2);
1194+
1195+
nrf_rpc_cmd_common_no_err(group, cmd, packet, len, handler,
1196+
handler_data);
1197+
}
1198+
1199+
void nrf_rpc_cmd_rsp_no_err(const struct nrf_rpc_group *group, uint8_t cmd,
1200+
uint8_t *packet, size_t len, const uint8_t **rsp_packet,
1201+
size_t *rsp_len)
1202+
{
1203+
void nrf_rpc_cmd_common_no_err(const struct nrf_rpc_group *group,
1204+
uint32_t cmd, uint8_t *packet,
1205+
size_t len, void *ptr1, void *ptr2);
1206+
1207+
nrf_rpc_cmd_common_no_err(group, cmd | 0x10000, packet, len, rsp_packet,
1208+
rsp_len);
1209+
}
1210+
11661211
/** Report an error that cannot be reported as a function return value */
11671212
void nrf_rpc_err(int code, enum nrf_rpc_err_src src,
11681213
const struct nrf_rpc_group *group, uint8_t id,

0 commit comments

Comments
 (0)