From 6202459d9fe65fcffd69448590a0bf9a2da1acaf Mon Sep 17 00:00:00 2001 From: Benedikt Schmidt Date: Wed, 4 Oct 2023 08:58:03 +0200 Subject: [PATCH] samples: fix thread function signatures Fix thread function signatures to avoid stack corruption on thread exit. Signed-off-by: Benedikt Schmidt --- samples/arch/smp/pi/src/main.c | 2 +- samples/arch/smp/pktqueue/src/main.c | 5 ++--- samples/bluetooth/ipsp/src/main.c | 8 +++++-- samples/net/mqtt_sn_publisher/src/common.h | 2 +- samples/net/mqtt_sn_publisher/src/main.c | 12 +++++++---- samples/net/mqtt_sn_publisher/src/udp.c | 13 ++++++++---- samples/net/sockets/can/src/main.c | 16 +++++++++----- .../sockets/dumb_http_server_mt/src/main.c | 4 ++-- .../net/sockets/echo_client/src/echo-client.c | 13 ++++++------ samples/net/sockets/echo_client/src/udp.c | 8 +++++-- samples/net/sockets/echo_server/src/tcp.c | 4 ++-- samples/net/sockets/net_mgmt/src/main.c | 10 ++++++--- samples/net/sockets/txtime/src/main.c | 16 ++++++++++---- samples/net/wpan_serial/src/main.c | 16 ++++++++++---- samples/net/wpanusb/src/wpanusb.c | 8 +++++-- samples/subsys/ipc/openamp/remote/src/main.c | 3 ++- samples/subsys/ipc/openamp/src/main.c | 3 ++- .../ipc/openamp_rsc_table/src/main_remote.c | 9 +++++--- .../ipc/rpmsg_service/remote/src/main.c | 3 ++- samples/subsys/ipc/rpmsg_service/src/main.c | 3 ++- samples/userspace/shared_mem/src/main.c | 21 +++++++++++++------ samples/userspace/shared_mem/src/main.h | 6 +++--- 22 files changed, 124 insertions(+), 61 deletions(-) diff --git a/samples/arch/smp/pi/src/main.c b/samples/arch/smp/pi/src/main.c index e141f8f5f1b..f5797c43f79 100644 --- a/samples/arch/smp/pi/src/main.c +++ b/samples/arch/smp/pi/src/main.c @@ -90,7 +90,7 @@ int main(void) for (i = 0; i < THREADS_NUM; i++) { k_thread_create(&tthread[i], tstack[i], STACK_SIZE, - (k_thread_entry_t)test_thread, + test_thread, (void *)&th_counter, (void *)th_buffer[i], NULL, K_PRIO_COOP(10), 0, K_NO_WAIT); } diff --git a/samples/arch/smp/pktqueue/src/main.c b/samples/arch/smp/pktqueue/src/main.c index 11d3ea36c73..07363a8d234 100644 --- a/samples/arch/smp/pktqueue/src/main.c +++ b/samples/arch/smp/pktqueue/src/main.c @@ -101,7 +101,6 @@ void test_thread(void *arg1, void *arg2, void *arg3) /* Thread that processes one pair of sender/receiver queue */ void queue_thread(void *arg1, void *arg2, void *arg3) { - ARG_UNUSED(arg1); ARG_UNUSED(arg2); ARG_UNUSED(arg3); @@ -117,7 +116,7 @@ void queue_thread(void *arg1, void *arg2, void *arg3) for (int i = 0; i < THREADS_NUM; i++) k_thread_create(&tthread[i+THREADS_NUM*queue_num], tstack[i+THREADS_NUM*queue_num], STACK_SIZE, - (k_thread_entry_t)test_thread, + test_thread, (void *)&sender[queue_num], (void *)&receiver[queue_num], (void *)&queue_num, K_PRIO_PREEMPT(10), 0, K_NO_WAIT); @@ -156,7 +155,7 @@ int main(void) for (int i = 0; i < QUEUE_NUM; i++) k_thread_create(&qthread[i], qstack[i], STACK_SIZE, - (k_thread_entry_t)queue_thread, + queue_thread, (void *)&sender[i], (void *)&receiver[i], (void *)&i, K_PRIO_PREEMPT(11), 0, K_NO_WAIT); diff --git a/samples/bluetooth/ipsp/src/main.c b/samples/bluetooth/ipsp/src/main.c index c4f1f87c169..a8c017140c3 100644 --- a/samples/bluetooth/ipsp/src/main.c +++ b/samples/bluetooth/ipsp/src/main.c @@ -285,8 +285,12 @@ static void setup_tcp_accept(struct net_context *tcp_recv6) } } -static void listen(void) +static void listen(void *p1, void *p2, void *p3) { + ARG_UNUSED(p1); + ARG_UNUSED(p2); + ARG_UNUSED(p3); + struct net_context *udp_recv6 = { 0 }; struct net_context *tcp_recv6 = { 0 }; @@ -313,7 +317,7 @@ int main(void) init_app(); k_thread_create(&thread_data, thread_stack, STACKSIZE, - (k_thread_entry_t)listen, + listen, NULL, NULL, NULL, K_PRIO_COOP(7), 0, K_NO_WAIT); return 0; } diff --git a/samples/net/mqtt_sn_publisher/src/common.h b/samples/net/mqtt_sn_publisher/src/common.h index 4b0fef32698..1cfbbc10450 100644 --- a/samples/net/mqtt_sn_publisher/src/common.h +++ b/samples/net/mqtt_sn_publisher/src/common.h @@ -23,4 +23,4 @@ extern struct k_mem_domain app_domain; #define THREAD_PRIORITY K_PRIO_PREEMPT(8) #endif -int start_thread(void); +void start_thread(void); diff --git a/samples/net/mqtt_sn_publisher/src/main.c b/samples/net/mqtt_sn_publisher/src/main.c index 665919ef50a..65436daea4d 100644 --- a/samples/net/mqtt_sn_publisher/src/main.c +++ b/samples/net/mqtt_sn_publisher/src/main.c @@ -83,12 +83,16 @@ static void init_app(void) } } -static int start_client(void) +static void start_client(void *p1, void *p2, void *p3) { + ARG_UNUSED(p1); + ARG_UNUSED(p2); + ARG_UNUSED(p3); + /* Wait for connection */ k_sem_take(&run_app, K_FOREVER); - return start_thread(); + start_thread(); } int main(void) @@ -107,9 +111,9 @@ int main(void) k_thread_access_grant(k_current_get(), &run_app); k_mem_domain_add_thread(&app_domain, k_current_get()); - k_thread_user_mode_enter((k_thread_entry_t)start_client, NULL, NULL, NULL); + k_thread_user_mode_enter(start_client, NULL, NULL, NULL); #else - exit(start_client()); + start_client(NULL, NULL, NULL); #endif return 0; } diff --git a/samples/net/mqtt_sn_publisher/src/udp.c b/samples/net/mqtt_sn_publisher/src/udp.c index 32a64fbccbd..70a09bdb89d 100644 --- a/samples/net/mqtt_sn_publisher/src/udp.c +++ b/samples/net/mqtt_sn_publisher/src/udp.c @@ -141,23 +141,28 @@ static void process_thread(void) LOG_ERR("Exiting thread: %d", err); } -int start_thread(void) +void start_thread(void) { int rc; #if defined(CONFIG_USERSPACE) rc = k_mem_domain_add_thread(&app_domain, udp_thread_id); if (rc < 0) { - return rc; + LOG_ERR("Failed: k_mem_domain_add_thread() %d", rc); + return; } #endif rc = k_thread_name_set(udp_thread_id, "udp"); if (rc < 0 && rc != -ENOSYS) { LOG_ERR("Failed: k_thread_name_set() %d", rc); - return rc; + return; } k_thread_start(udp_thread_id); - return k_thread_join(udp_thread_id, K_FOREVER); + rc = k_thread_join(udp_thread_id, K_FOREVER); + + if (rc != 0) { + LOG_ERR("Failed: k_thread_join() %d", rc); + } } diff --git a/samples/net/sockets/can/src/main.c b/samples/net/sockets/can/src/main.c index 2f86b63eaf1..506157c6afe 100644 --- a/samples/net/sockets/can/src/main.c +++ b/samples/net/sockets/can/src/main.c @@ -39,8 +39,12 @@ static const struct can_filter zfilter = { static struct socketcan_filter sock_filter; -static void tx(int *can_fd) +static void tx(void *p1, void *p2, void *p3) { + ARG_UNUSED(p2); + ARG_UNUSED(p3); + + int *can_fd = p1; int fd = POINTER_TO_INT(can_fd); struct can_frame zframe = {0}; struct socketcan_frame sframe = {0}; @@ -95,9 +99,11 @@ static int create_socket(const struct socketcan_filter *sfilter) return fd; } -static void rx(int *can_fd, int *do_close_period, - const struct socketcan_filter *sfilter) +static void rx(void *p1, void *p2, void *p3) { + int *can_fd = p1; + int *do_close_period = p2; + const struct socketcan_filter *sfilter = p3; int close_period = POINTER_TO_INT(do_close_period); int fd = POINTER_TO_INT(can_fd); struct sockaddr_can can_addr; @@ -205,7 +211,7 @@ static int setup_socket(void) /* Delay TX startup so that RX is ready to receive */ tx_tid = k_thread_create(&tx_data, tx_stack, K_THREAD_STACK_SIZEOF(tx_stack), - (k_thread_entry_t)tx, INT_TO_POINTER(fd), + tx, INT_TO_POINTER(fd), NULL, NULL, PRIORITY, 0, K_SECONDS(1)); if (!tx_tid) { ret = -ENOENT; @@ -225,7 +231,7 @@ static int setup_socket(void) if (fd >= 0) { rx_tid = k_thread_create(&rx_data, rx_stack, K_THREAD_STACK_SIZEOF(rx_stack), - (k_thread_entry_t)rx, + rx, INT_TO_POINTER(fd), INT_TO_POINTER(CLOSE_PERIOD), &sock_filter, PRIORITY, 0, K_NO_WAIT); diff --git a/samples/net/sockets/dumb_http_server_mt/src/main.c b/samples/net/sockets/dumb_http_server_mt/src/main.c index 714bbc5a67b..baa295b7f50 100644 --- a/samples/net/sockets/dumb_http_server_mt/src/main.c +++ b/samples/net/sockets/dumb_http_server_mt/src/main.c @@ -287,7 +287,7 @@ static int process_tcp(int *sock, int *accepted) &tcp6_handler_thread[slot], tcp6_handler_stack[slot], K_THREAD_STACK_SIZEOF(tcp6_handler_stack[slot]), - (k_thread_entry_t)client_conn_handler, + client_conn_handler, INT_TO_POINTER(slot), &accepted[slot], &tcp6_handler_tid[slot], @@ -302,7 +302,7 @@ static int process_tcp(int *sock, int *accepted) &tcp4_handler_thread[slot], tcp4_handler_stack[slot], K_THREAD_STACK_SIZEOF(tcp4_handler_stack[slot]), - (k_thread_entry_t)client_conn_handler, + client_conn_handler, INT_TO_POINTER(slot), &accepted[slot], &tcp4_handler_tid[slot], diff --git a/samples/net/sockets/echo_client/src/echo-client.c b/samples/net/sockets/echo_client/src/echo-client.c index 3738c758b15..c78b14952e6 100644 --- a/samples/net/sockets/echo_client/src/echo-client.c +++ b/samples/net/sockets/echo_client/src/echo-client.c @@ -279,8 +279,12 @@ static void init_app(void) init_udp(); } -static int start_client(void) +static void start_client(void *p1, void *p2, void *p3) { + ARG_UNUSED(p1); + ARG_UNUSED(p2); + ARG_UNUSED(p3); + int iterations = CONFIG_NET_SAMPLE_SEND_ITERATIONS; int i = 0; int ret; @@ -305,8 +309,6 @@ static int start_client(void) stop_udp_and_tcp(); } - - return ret; } int main(void) @@ -327,10 +329,9 @@ int main(void) k_thread_access_grant(k_current_get(), &run_app); k_mem_domain_add_thread(&app_domain, k_current_get()); - k_thread_user_mode_enter((k_thread_entry_t)start_client, NULL, NULL, - NULL); + k_thread_user_mode_enter(start_client, NULL, NULL, NULL); #else - exit(start_client()); + start_client(NULL, NULL, NULL); #endif return 0; } diff --git a/samples/net/sockets/echo_client/src/udp.c b/samples/net/sockets/echo_client/src/udp.c index 1889fdb591d..e5b7ea1dae0 100644 --- a/samples/net/sockets/echo_client/src/udp.c +++ b/samples/net/sockets/echo_client/src/udp.c @@ -40,8 +40,12 @@ static int send_udp_data(struct data *data); static void wait_reply(struct k_timer *timer); static void wait_transmit(struct k_timer *timer); -static void process_udp_tx(void) +static void process_udp_tx(void *p1, void *p2, void *p3) { + ARG_UNUSED(p1); + ARG_UNUSED(p2); + ARG_UNUSED(p3); + struct k_poll_event events[] = { K_POLL_EVENT_INITIALIZER(K_POLL_TYPE_SIGNAL, K_POLL_MODE_NOTIFY_ONLY, @@ -317,7 +321,7 @@ int start_udp(void) k_thread_create(&udp_tx_thread, udp_tx_thread_stack, K_THREAD_STACK_SIZEOF(udp_tx_thread_stack), - (k_thread_entry_t)process_udp_tx, + process_udp_tx, NULL, NULL, NULL, THREAD_PRIORITY, IS_ENABLED(CONFIG_USERSPACE) ? K_USER | K_INHERIT_PERMS : 0, diff --git a/samples/net/sockets/echo_server/src/tcp.c b/samples/net/sockets/echo_server/src/tcp.c index ffc6d69bc36..1a6555d43c3 100644 --- a/samples/net/sockets/echo_server/src/tcp.c +++ b/samples/net/sockets/echo_server/src/tcp.c @@ -243,7 +243,7 @@ static int process_tcp(struct data *data) &tcp6_handler_thread[slot], tcp6_handler_stack[slot], K_THREAD_STACK_SIZEOF(tcp6_handler_stack[slot]), - (k_thread_entry_t)handle_data, + handle_data, INT_TO_POINTER(slot), data, &tcp6_handler_in_use[slot], THREAD_PRIORITY, IS_ENABLED(CONFIG_USERSPACE) ? K_USER | @@ -267,7 +267,7 @@ static int process_tcp(struct data *data) &tcp4_handler_thread[slot], tcp4_handler_stack[slot], K_THREAD_STACK_SIZEOF(tcp4_handler_stack[slot]), - (k_thread_entry_t)handle_data, + handle_data, INT_TO_POINTER(slot), data, &tcp4_handler_in_use[slot], THREAD_PRIORITY, IS_ENABLED(CONFIG_USERSPACE) ? K_USER | diff --git a/samples/net/sockets/net_mgmt/src/main.c b/samples/net/sockets/net_mgmt/src/main.c index 2e6813b54cd..877e5e41d5c 100644 --- a/samples/net/sockets/net_mgmt/src/main.c +++ b/samples/net/sockets/net_mgmt/src/main.c @@ -82,8 +82,12 @@ static char *get_ip_addr(char *ipaddr, size_t len, sa_family_t family, return buf; } -static void listener(void) +static void listener(void *p1, void *p2, void *p3) { + ARG_UNUSED(p1); + ARG_UNUSED(p2); + ARG_UNUSED(p3); + struct sockaddr_nm sockaddr; struct sockaddr_nm event_addr; socklen_t event_addr_len; @@ -163,10 +167,10 @@ int main(void) k_thread_start(trigger_events_thread_id); if (IS_ENABLED(CONFIG_USERSPACE)) { - k_thread_user_mode_enter((k_thread_entry_t)listener, + k_thread_user_mode_enter(listener, NULL, NULL, NULL); } else { - listener(); + listener(NULL, NULL, NULL); } return 0; } diff --git a/samples/net/sockets/txtime/src/main.c b/samples/net/sockets/txtime/src/main.c index a4a63732398..481312d1afe 100644 --- a/samples/net/sockets/txtime/src/main.c +++ b/samples/net/sockets/txtime/src/main.c @@ -127,8 +127,12 @@ static void event_handler(struct net_mgmt_event_callback *cb, } } -static void rx(struct app_data *data) +static void rx(void *p1, void *p2, void *p3) { + ARG_UNUSED(p2); + ARG_UNUSED(p3); + + struct app_data *data = p1; static uint8_t recv_buf[sizeof(txtime_str)]; struct sockaddr src; socklen_t addr_len = data->peer_addr_len; @@ -143,8 +147,12 @@ static void rx(struct app_data *data) } } -static void tx(struct app_data *data) +static void tx(void *p1, void *p2, void *p3) { + ARG_UNUSED(p2); + ARG_UNUSED(p3); + + struct app_data *data = p1; struct net_ptp_time time; struct msghdr msg; struct cmsghdr *cmsg; @@ -620,7 +628,7 @@ int main(void) tx_tid = k_thread_create(&tx_thread, tx_stack, K_THREAD_STACK_SIZEOF(tx_stack), - (k_thread_entry_t)tx, &peer_data, + tx, &peer_data, NULL, NULL, THREAD_PRIORITY, 0, K_FOREVER); if (!tx_tid) { @@ -632,7 +640,7 @@ int main(void) rx_tid = k_thread_create(&rx_thread, rx_stack, K_THREAD_STACK_SIZEOF(rx_stack), - (k_thread_entry_t)rx, &peer_data, + rx, &peer_data, NULL, NULL, THREAD_PRIORITY, 0, K_FOREVER); if (!rx_tid) { diff --git a/samples/net/wpan_serial/src/main.c b/samples/net/wpan_serial/src/main.c index 1e702dc9590..04b98a449bb 100644 --- a/samples/net/wpan_serial/src/main.c +++ b/samples/net/wpan_serial/src/main.c @@ -299,8 +299,12 @@ static void process_config(struct net_pkt *pkt) } } -static void rx_thread(void) +static void rx_thread(void *p1, void *p2, void *p3) { + ARG_UNUSED(p1); + ARG_UNUSED(p2); + ARG_UNUSED(p3); + LOG_DBG("RX thread started"); while (true) { @@ -386,8 +390,12 @@ static int try_write(uint8_t *data, uint16_t len) /** * TX - transmit to SLIP interface */ -static void tx_thread(void) +static void tx_thread(void *p1, void *p2, void *p3) { + ARG_UNUSED(p1); + ARG_UNUSED(p2); + ARG_UNUSED(p3); + LOG_DBG("TX thread started"); while (true) { @@ -421,7 +429,7 @@ static void init_rx_queue(void) k_thread_create(&rx_thread_data, rx_stack, K_THREAD_STACK_SIZEOF(rx_stack), - (k_thread_entry_t)rx_thread, + rx_thread, NULL, NULL, NULL, THREAD_PRIORITY, 0, K_NO_WAIT); } @@ -431,7 +439,7 @@ static void init_tx_queue(void) k_thread_create(&tx_thread_data, tx_stack, K_THREAD_STACK_SIZEOF(tx_stack), - (k_thread_entry_t)tx_thread, + tx_thread, NULL, NULL, NULL, THREAD_PRIORITY, 0, K_NO_WAIT); } diff --git a/samples/net/wpanusb/src/wpanusb.c b/samples/net/wpanusb/src/wpanusb.c index a4e1f88403f..7cee37340c3 100644 --- a/samples/net/wpanusb/src/wpanusb.c +++ b/samples/net/wpanusb/src/wpanusb.c @@ -295,8 +295,12 @@ static int tx(struct net_pkt *pkt) return ret; } -static void tx_thread(void) +static void tx_thread(void *p1, void *p2, void *p3) { + ARG_UNUSED(p1); + ARG_UNUSED(p2); + ARG_UNUSED(p3); + LOG_DBG("Tx thread started"); while (1) { @@ -353,7 +357,7 @@ static void init_tx_queue(void) k_thread_create(&tx_thread_data, tx_stack, K_THREAD_STACK_SIZEOF(tx_stack), - (k_thread_entry_t)tx_thread, + tx_thread, NULL, NULL, NULL, THREAD_PRIORITY, 0, K_NO_WAIT); } diff --git a/samples/subsys/ipc/openamp/remote/src/main.c b/samples/subsys/ipc/openamp/remote/src/main.c index 337d0114531..06622d49e44 100644 --- a/samples/subsys/ipc/openamp/remote/src/main.c +++ b/samples/subsys/ipc/openamp/remote/src/main.c @@ -144,6 +144,7 @@ void app_task(void *arg1, void *arg2, void *arg3) ARG_UNUSED(arg1); ARG_UNUSED(arg2); ARG_UNUSED(arg3); + int status = 0; unsigned int message = 0U; struct metal_device *device; @@ -259,7 +260,7 @@ int main(void) { printk("Starting application thread!\n"); k_thread_create(&thread_data, thread_stack, APP_TASK_STACK_SIZE, - (k_thread_entry_t)app_task, + app_task, NULL, NULL, NULL, K_PRIO_COOP(7), 0, K_NO_WAIT); return 0; } diff --git a/samples/subsys/ipc/openamp/src/main.c b/samples/subsys/ipc/openamp/src/main.c index b2a06ec8a8c..5b2ce5fddbb 100644 --- a/samples/subsys/ipc/openamp/src/main.c +++ b/samples/subsys/ipc/openamp/src/main.c @@ -168,6 +168,7 @@ void app_task(void *arg1, void *arg2, void *arg3) ARG_UNUSED(arg1); ARG_UNUSED(arg2); ARG_UNUSED(arg3); + int status = 0; unsigned int message = 0U; struct metal_device *device; @@ -284,7 +285,7 @@ int main(void) { printk("Starting application thread!\n"); k_thread_create(&thread_data, thread_stack, APP_TASK_STACK_SIZE, - (k_thread_entry_t)app_task, + app_task, NULL, NULL, NULL, K_PRIO_COOP(7), 0, K_NO_WAIT); #if defined(CONFIG_SOC_MPS2_AN521) || \ diff --git a/samples/subsys/ipc/openamp_rsc_table/src/main_remote.c b/samples/subsys/ipc/openamp_rsc_table/src/main_remote.c index a5bd2e9c76c..ebee382cdf8 100644 --- a/samples/subsys/ipc/openamp_rsc_table/src/main_remote.c +++ b/samples/subsys/ipc/openamp_rsc_table/src/main_remote.c @@ -276,6 +276,7 @@ void app_rpmsg_client_sample(void *arg1, void *arg2, void *arg3) ARG_UNUSED(arg1); ARG_UNUSED(arg2); ARG_UNUSED(arg3); + unsigned int msg_cnt = 0; int ret = 0; @@ -302,6 +303,7 @@ void app_rpmsg_tty(void *arg1, void *arg2, void *arg3) ARG_UNUSED(arg1); ARG_UNUSED(arg2); ARG_UNUSED(arg3); + unsigned char tx_buff[512]; int ret = 0; @@ -335,6 +337,7 @@ void rpmsg_mng_task(void *arg1, void *arg2, void *arg3) ARG_UNUSED(arg1); ARG_UNUSED(arg2); ARG_UNUSED(arg3); + unsigned char *msg; unsigned int len; int ret = 0; @@ -375,13 +378,13 @@ int main(void) { printk("Starting application threads!\n"); k_thread_create(&thread_mng_data, thread_mng_stack, APP_TASK_STACK_SIZE, - (k_thread_entry_t)rpmsg_mng_task, + rpmsg_mng_task, NULL, NULL, NULL, K_PRIO_COOP(8), 0, K_NO_WAIT); k_thread_create(&thread_rp__client_data, thread_rp__client_stack, APP_TASK_STACK_SIZE, - (k_thread_entry_t)app_rpmsg_client_sample, + app_rpmsg_client_sample, NULL, NULL, NULL, K_PRIO_COOP(7), 0, K_NO_WAIT); k_thread_create(&thread_tty_data, thread_tty_stack, APP_TTY_TASK_STACK_SIZE, - (k_thread_entry_t)app_rpmsg_tty, + app_rpmsg_tty, NULL, NULL, NULL, K_PRIO_COOP(7), 0, K_NO_WAIT); return 0; } diff --git a/samples/subsys/ipc/rpmsg_service/remote/src/main.c b/samples/subsys/ipc/rpmsg_service/remote/src/main.c index 9960a113267..de6de636ff5 100644 --- a/samples/subsys/ipc/rpmsg_service/remote/src/main.c +++ b/samples/subsys/ipc/rpmsg_service/remote/src/main.c @@ -54,6 +54,7 @@ void app_task(void *arg1, void *arg2, void *arg3) ARG_UNUSED(arg1); ARG_UNUSED(arg2); ARG_UNUSED(arg3); + int status = 0; unsigned int message = 0U; @@ -79,7 +80,7 @@ int main(void) { printk("Starting application thread!\n"); k_thread_create(&thread_data, thread_stack, APP_TASK_STACK_SIZE, - (k_thread_entry_t)app_task, + app_task, NULL, NULL, NULL, K_PRIO_COOP(7), 0, K_NO_WAIT); return 0; } diff --git a/samples/subsys/ipc/rpmsg_service/src/main.c b/samples/subsys/ipc/rpmsg_service/src/main.c index f849bb3ee96..f90df936565 100644 --- a/samples/subsys/ipc/rpmsg_service/src/main.c +++ b/samples/subsys/ipc/rpmsg_service/src/main.c @@ -55,6 +55,7 @@ void app_task(void *arg1, void *arg2, void *arg3) ARG_UNUSED(arg1); ARG_UNUSED(arg2); ARG_UNUSED(arg3); + int status = 0; unsigned int message = 0U; @@ -88,7 +89,7 @@ int main(void) { printk("Starting application thread!\n"); k_thread_create(&thread_data, thread_stack, APP_TASK_STACK_SIZE, - (k_thread_entry_t)app_task, + app_task, NULL, NULL, NULL, K_PRIO_COOP(7), 0, K_NO_WAIT); #if defined(CONFIG_SOC_MPS2_AN521) || \ diff --git a/samples/userspace/shared_mem/src/main.c b/samples/userspace/shared_mem/src/main.c index 7eaecfc254a..c8b9adbae1b 100644 --- a/samples/userspace/shared_mem/src/main.c +++ b/samples/userspace/shared_mem/src/main.c @@ -133,7 +133,7 @@ int main(void) * then add the thread to the domain. */ tENC = k_thread_create(&enc_thread, enc_stack, STACKSIZE, - (k_thread_entry_t)enc, NULL, NULL, NULL, + enc, NULL, NULL, NULL, -1, K_USER, K_FOREVER); k_thread_access_grant(tENC, &allforone); @@ -150,7 +150,7 @@ int main(void) tPT = k_thread_create(&pt_thread, pt_stack, STACKSIZE, - (k_thread_entry_t)pt, NULL, NULL, NULL, + pt, NULL, NULL, NULL, -1, K_USER, K_FOREVER); k_thread_access_grant(tPT, &allforone); @@ -163,7 +163,7 @@ int main(void) printk("pt_domain Created\n"); tCT = k_thread_create(&ct_thread, ct_stack, STACKSIZE, - (k_thread_entry_t)ct, NULL, NULL, NULL, + ct, NULL, NULL, NULL, -1, K_USER, K_FOREVER); k_thread_access_grant(tCT, &allforone); @@ -204,8 +204,11 @@ int main(void) * Copy memory from pt thread and encrypt to a local buffer * then copy to the ct thread. */ -void enc(void) +void enc(void *p1, void *p2, void *p3) { + ARG_UNUSED(p1); + ARG_UNUSED(p2); + ARG_UNUSED(p3); int index, index_out; @@ -252,8 +255,11 @@ void enc(void) * It can be extended to receive data from a serial port * and pass the data to enc */ -void pt(void) +void pt(void *p1, void *p2, void *p3) { + ARG_UNUSED(p1); + ARG_UNUSED(p2); + ARG_UNUSED(p3); k_sleep(K_MSEC(20)); while (1) { @@ -282,8 +288,11 @@ void pt(void) * CT waits for fBUFOUT = 1 then copies * the message clears the flag and prints */ -void ct(void) +void ct(void *p1, void *p2, void *p3) { + ARG_UNUSED(p1); + ARG_UNUSED(p2); + ARG_UNUSED(p3); char tbuf[60]; diff --git a/samples/userspace/shared_mem/src/main.h b/samples/userspace/shared_mem/src/main.h index 3fa72b5df1f..40c18364c96 100644 --- a/samples/userspace/shared_mem/src/main.h +++ b/samples/userspace/shared_mem/src/main.h @@ -20,9 +20,9 @@ #include #endif -void enc(void); -void pt(void); -void ct(void); +void enc(void *p1, void *p2, void *p3); +void pt(void *p1, void *p2, void *p3); +void ct(void *p1, void *p2, void *p3); #define _app_user_d K_APP_DMEM(user_part) #define _app_user_b K_APP_BMEM(user_part)