From aa2ecf621638a652d587894852e6472191302c6c Mon Sep 17 00:00:00 2001 From: Oleg Hahm Date: Wed, 6 Aug 2014 09:44:31 +0200 Subject: [PATCH] initialize kernel_pid_t correctly --- boards/avsextrem/drivers/avsextrem-smb380.c | 2 +- boards/msb-430-common/uart1.c | 2 +- boards/msba2-common/drivers/msba2-uart0.c | 2 +- boards/redbee-econotag/drivers/redbee_uart1.c | 2 +- boards/redbee-econotag/drivers/redbee_uart2.c | 2 +- boards/telosb/uart.c | 2 +- boards/wsn430-common/wsn430-uart0.c | 2 +- boards/z1/uart.c | 2 +- cpu/cc430/cc430-rtc.c | 4 ++-- cpu/native/net/interface.c | 4 ++-- cpu/x86/x86_rtc.c | 2 +- examples/ccn-lite-client/main.c | 8 ++++---- examples/ccn-lite-relay/main.c | 2 +- sys/net/ccn_lite/ccnl-ext-appserver.c | 2 +- sys/net/network_layer/sixlowpan/border/border.c | 4 ++-- sys/net/network_layer/sixlowpan/border/flowcontrol.c | 2 +- sys/net/routing/rpl/rpl.c | 2 +- sys/net/routing/rpl/trickle.c | 8 ++++---- sys/net/transport_layer/destiny/tcp.c | 2 +- sys/posix/pthread/pthread.c | 6 +++--- sys/uart0/uart0.c | 2 +- tests/nativenet/main.c | 2 +- tests/posix_semaphore/main.c | 2 +- tests/queue_fairness/main.c | 2 +- tests/thread_cooperation/main.c | 2 +- tests/thread_msg_block_w_queue/main.c | 2 +- tests/thread_msg_block_wo_queue/main.c | 2 +- tests/thread_msg_seq/main.c | 2 +- 28 files changed, 39 insertions(+), 39 deletions(-) diff --git a/boards/avsextrem/drivers/avsextrem-smb380.c b/boards/avsextrem/drivers/avsextrem-smb380.c index a37d3f7b5b..3b75e4a562 100644 --- a/boards/avsextrem/drivers/avsextrem-smb380.c +++ b/boards/avsextrem/drivers/avsextrem-smb380.c @@ -44,7 +44,7 @@ #include "lpc2387.h" -kernel_pid_t simple_pid; +kernel_pid_t simple_pid = KERNEL_PID_UNDEF; int16_t simple_buffer[4]; volatile int16_t *ringBuff_X = NULL; diff --git a/boards/msb-430-common/uart1.c b/boards/msb-430-common/uart1.c index 760eeb1112..524907924a 100644 --- a/boards/msb-430-common/uart1.c +++ b/boards/msb-430-common/uart1.c @@ -68,7 +68,7 @@ interrupt(USART1RX_VECTOR) usart0irq(void) (void) c; } #ifdef MODULE_UART0 - else if (uart0_handler_pid) { + else if (uart0_handler_pid != KERNEL_PID_UNDEF) { volatile int c = U1RXBUF; uart0_handle_incoming(c); uart0_notify_thread(); diff --git a/boards/msba2-common/drivers/msba2-uart0.c b/boards/msba2-common/drivers/msba2-uart0.c index a23dbba077..0e2504a121 100644 --- a/boards/msba2-common/drivers/msba2-uart0.c +++ b/boards/msba2-common/drivers/msba2-uart0.c @@ -128,7 +128,7 @@ void UART0_IRQHandler(void) case UIIR_CTI_INT: // Character Timeout Indicator case UIIR_RDA_INT: // Receive Data Available #ifdef MODULE_UART0 - if (uart0_handler_pid) { + if (uart0_handler_pid != KERNEL_PID_UNDEF) { do { int c = U0RBR; uart0_handle_incoming(c); diff --git a/boards/redbee-econotag/drivers/redbee_uart1.c b/boards/redbee-econotag/drivers/redbee_uart1.c index 36dbdfec9e..7c4b1f861c 100644 --- a/boards/redbee-econotag/drivers/redbee_uart1.c +++ b/boards/redbee-econotag/drivers/redbee_uart1.c @@ -17,7 +17,7 @@ void uart1_isr(void) if (UART1->USTATbits.RXRDY == 1) { #ifdef MODULE_UART0 - if (uart0_handler_pid) { + if (uart0_handler_pid != KERNEL_PID_UNDEF) { uint32_t i = 0; while (UART1->RXCON != 0) { uart0_handle_incoming(UART1->DATA); diff --git a/boards/redbee-econotag/drivers/redbee_uart2.c b/boards/redbee-econotag/drivers/redbee_uart2.c index 84c8ace068..578d2a8296 100644 --- a/boards/redbee-econotag/drivers/redbee_uart2.c +++ b/boards/redbee-econotag/drivers/redbee_uart2.c @@ -17,7 +17,7 @@ void uart2_isr(void) if (UART2->USTATbits.RXRDY == 1) { #ifdef MODULE_UART0 - if (uart0_handler_pid) { + if (uart0_handler_pid != KERNEL_PID_UNDEF) { uint32_t i = 0; while (UART2->RXCON != 0) { uart0_handle_incoming(UART2->DATA); diff --git a/boards/telosb/uart.c b/boards/telosb/uart.c index 8b8164fd96..185d1920e9 100644 --- a/boards/telosb/uart.c +++ b/boards/telosb/uart.c @@ -107,7 +107,7 @@ interrupt(USART1RX_VECTOR) usart1irq(void) } #ifdef MODULE_UART0 - else if (uart0_handler_pid) { + else if (uart0_handler_pid != KERNEL_PID_UNDEF) { volatile int c = U1RXBUF; uart0_handle_incoming(c); uart0_notify_thread(); diff --git a/boards/wsn430-common/wsn430-uart0.c b/boards/wsn430-common/wsn430-uart0.c index 30be95bfe2..9a82348ad2 100644 --- a/boards/wsn430-common/wsn430-uart0.c +++ b/boards/wsn430-common/wsn430-uart0.c @@ -54,7 +54,7 @@ interrupt(USART0RX_VECTOR) usart0irq(void) { dummy = U0RXBUF; } #ifdef MODULE_UART0 - else if (uart0_handler_pid) { + else if (uart0_handler_pid != KERNEL_PID_UNDEF) { dummy = U0RXBUF; uart0_handle_incoming(dummy); uart0_notify_thread(); diff --git a/boards/z1/uart.c b/boards/z1/uart.c index 30641dbaa2..17119f99a3 100644 --- a/boards/z1/uart.c +++ b/boards/z1/uart.c @@ -122,7 +122,7 @@ interrupt(USCIAB0RX_VECTOR) __attribute__ ((naked)) usart1irq(void) /* Clear error flags by forcing a dummy read. */ c = UCA0RXBUF; #ifdef MODULE_UART0 - } else if (uart0_handler_pid) { + } else if (uart0_handler_pid != KERNEL_PID_UNDEF) { /* All went well -> let's signal the reception to adequate callbacks */ c = UCA0RXBUF; uart0_handle_incoming(c); diff --git a/cpu/cc430/cc430-rtc.c b/cpu/cc430/cc430-rtc.c index ea10e9e7ef..74e737a94b 100644 --- a/cpu/cc430/cc430-rtc.c +++ b/cpu/cc430/cc430-rtc.c @@ -26,7 +26,7 @@ directory for more details. //static volatile time_t epoch; static struct tm time_to_set; static int set_time = 0; -kernel_pid_t rtc_second_pid = 0; +kernel_pid_t rtc_second_pid = KERNEL_PID_UNDEF; /*---------------------------------------------------------------------------*/ void rtc_init(void) @@ -195,7 +195,7 @@ interrupt(RTC_VECTOR) __attribute__((naked)) rtc_isr(void) RTCYEARH = (time_to_set.tm_year + 1900) >> 0x08; } - if (rtc_second_pid) { + if (rtc_second_pid != KERNEL_PID_UNDEF) { static msg_t m; m.type = RTC_SECOND; msg_send_int(&m, rtc_second_pid); diff --git a/cpu/native/net/interface.c b/cpu/native/net/interface.c index b0d085f34a..ddffc53141 100644 --- a/cpu/native/net/interface.c +++ b/cpu/native/net/interface.c @@ -45,7 +45,7 @@ static volatile uint8_t rx_buffer_next; uint8_t _native_net_chan; uint16_t _native_net_pan; uint8_t _native_net_monitor; -static int _native_net_tpid; +static kernel_pid_t _native_net_tpid = KERNEL_PID_UNDEF; radio_address_t _native_net_addr; uint64_t _native_net_addr_long; @@ -203,7 +203,7 @@ void _nativenet_handle_packet(radio_packet_t *packet) _nativenet_rx_buffer[rx_buffer_next].packet.data = (uint8_t *) &_nativenet_rx_buffer[rx_buffer_next].data; /* notify transceiver thread if any */ - if (_native_net_tpid) { + if (_native_net_tpid != KERNEL_PID_UNDEF) { DEBUG("_nativenet_handle_packet: notifying transceiver thread!\n"); msg_t m; m.type = (uint16_t) RCV_PKT_NATIVE; diff --git a/cpu/x86/x86_rtc.c b/cpu/x86/x86_rtc.c index 1a7f510d43..fbc6b5bb4b 100644 --- a/cpu/x86/x86_rtc.c +++ b/cpu/x86/x86_rtc.c @@ -42,7 +42,7 @@ static bool valid; static int32_t alarm_msg_content, periodic_msg_content, update_msg_content; -static unsigned alarm_pid = KERNEL_PID_UNDEF, periodic_pid = KERNEL_PID_NULL, update_pid = KERNEL_PID_NULL; +static unsigned alarm_pid = KERNEL_PID_UNDEF, periodic_pid = KERNEL_PID_UNDEF, update_pid = KERNEL_PID_UNDEF; static void alarm_callback_default(uint8_t reg_c) { diff --git a/examples/ccn-lite-client/main.c b/examples/ccn-lite-client/main.c index cc2a8fec07..438883cb2c 100644 --- a/examples/ccn-lite-client/main.c +++ b/examples/ccn-lite-client/main.c @@ -47,7 +47,7 @@ char relay_stack[KERNEL_CONF_STACKSIZE_MAIN]; #if RIOT_CCN_APPSERVER char appserver_stack[KERNEL_CONF_STACKSIZE_MAIN]; #endif -kernel_pid_t relay_pid, appserver_pid; +kernel_pid_t relay_pid = KERNEL_PID_UNDEF, appserver_pid = KERNEL_PID_UNDEF; #define SHELL_MSG_BUFFER_SIZE (64) msg_t msg_buffer_shell[SHELL_MSG_BUFFER_SIZE]; @@ -64,7 +64,7 @@ static void riot_ccn_appserver(int argc, char **argv) (void) argc; /* the function takes no arguments */ (void) argv; - if (appserver_pid) { + if (appserver_pid != KERNEL_PID_UNDEF) { /* already running */ return; } @@ -126,7 +126,7 @@ static void riot_ccn_register_prefix(int argc, char **argv) static void riot_ccn_relay_config(int argc, char **argv) { - if (!relay_pid) { + if (relay_pid == KERNEL_PID_UNDEF) { puts("ccnl stack not running"); return; } @@ -173,7 +173,7 @@ static void riot_ccn_transceiver_start(int relay_pid) static void riot_ccn_relay_start(void) { - if (relay_pid) { + if (relay_pid != KERNEL_PID_UNDEF) { DEBUG("ccn-lite relay on thread_id %d...please stop it first!\n", relay_pid); /* already running */ return; diff --git a/examples/ccn-lite-relay/main.c b/examples/ccn-lite-relay/main.c index 1fd9b54d65..86288ddaf5 100644 --- a/examples/ccn-lite-relay/main.c +++ b/examples/ccn-lite-relay/main.c @@ -31,7 +31,7 @@ // ccn #include "ccn_lite/ccnl-riot.h" -kernel_pid_t relay_pid; +kernel_pid_t relay_pid = KERNEL_PID_UNDEF; char t2_stack[KERNEL_CONF_STACKSIZE_MAIN]; diff --git a/sys/net/ccn_lite/ccnl-ext-appserver.c b/sys/net/ccn_lite/ccnl-ext-appserver.c index 400de7a8fa..da4947a102 100644 --- a/sys/net/ccn_lite/ccnl-ext-appserver.c +++ b/sys/net/ccn_lite/ccnl-ext-appserver.c @@ -37,7 +37,7 @@ /** message buffer */ msg_t msg_buffer_appserver[APPSERVER_MSG_BUFFER_SIZE]; -kernel_pid_t relay_pid; +kernel_pid_t relay_pid = KERNEL_PID_UNDEF; char prefix[] = "/riot/appserver/"; static int appserver_sent_content(uint8_t *buf, int len, kernel_pid_t from) diff --git a/sys/net/network_layer/sixlowpan/border/border.c b/sys/net/network_layer/sixlowpan/border/border.c index f3c73eefa1..5af44877fb 100644 --- a/sys/net/network_layer/sixlowpan/border/border.c +++ b/sys/net/network_layer/sixlowpan/border/border.c @@ -44,7 +44,7 @@ #define READER_STACK_SIZE (KERNEL_CONF_STACKSIZE_DEFAULT) char serial_reader_stack[READER_STACK_SIZE]; -kernel_pid_t serial_reader_pid; +kernel_pid_t serial_reader_pid = KERNEL_PID_UNDEF; uint8_t serial_out_buf[BORDER_BUFFER_SIZE]; uint8_t serial_in_buf[BORDER_BUFFER_SIZE]; @@ -138,7 +138,7 @@ int sixlowpan_lowpan_border_init(int if_id) border_process_lowpan, "border_process_lowpan"); - if (ip_process_pid < 0) { + if (ip_process_pid != KERNEL_PID_UNDEF) { return 0; } diff --git a/sys/net/network_layer/sixlowpan/border/flowcontrol.c b/sys/net/network_layer/sixlowpan/border/flowcontrol.c index f62cb1cc98..b09e3f2fc7 100644 --- a/sys/net/network_layer/sixlowpan/border/flowcontrol.c +++ b/sys/net/network_layer/sixlowpan/border/flowcontrol.c @@ -32,7 +32,7 @@ static int set_timeout(vtimer_t *timeout, timex_t val, void *args); static void sending_slot(void); char sending_slot_stack[SENDING_SLOT_STACK_SIZE]; -kernel_pid_t sending_slot_pid; +kernel_pid_t sending_slot_pid = KERNEL_PID_UNDEF; flowcontrol_stat_t slwin_stat; sem_t connection_established; diff --git a/sys/net/routing/rpl/rpl.c b/sys/net/routing/rpl/rpl.c index d73f50eb3f..83bd0f73b0 100644 --- a/sys/net/routing/rpl/rpl.c +++ b/sys/net/routing/rpl/rpl.c @@ -49,7 +49,7 @@ char addr_str[IPV6_MAX_ADDR_STR_LEN]; /* global variables */ rpl_of_t *rpl_objective_functions[NUMBER_IMPLEMENTED_OFS]; rpl_routing_entry_t rpl_routing_table[RPL_MAX_ROUTING_ENTRIES]; -kernel_pid_t rpl_process_pid; +kernel_pid_t rpl_process_pid = KERNEL_PID_UNDEF; mutex_t rpl_recv_mutex = MUTEX_INIT; mutex_t rpl_send_mutex = MUTEX_INIT; msg_t rpl_msg_queue[RPL_PKT_RECV_BUF_SIZE]; diff --git a/sys/net/routing/rpl/trickle.c b/sys/net/routing/rpl/trickle.c index 0c87b2f277..c56cb7f3d2 100644 --- a/sys/net/routing/rpl/trickle.c +++ b/sys/net/routing/rpl/trickle.c @@ -33,10 +33,10 @@ static char interval_over_buf[TRICKLE_INTERVAL_STACKSIZE]; static char dao_delay_over_buf[DAO_DELAY_STACKSIZE]; static char routing_table_buf[RT_STACKSIZE]; -kernel_pid_t timer_over_pid; -kernel_pid_t interval_over_pid; -kernel_pid_t dao_delay_over_pid; -kernel_pid_t rt_timer_over_pid; +kernel_pid_t timer_over_pid = KERNEL_PID_UNDEF; +kernel_pid_t interval_over_pid = KERNEL_PID_UNDEF; +kernel_pid_t dao_delay_over_pid = KERNEL_PID_UNDEF; +kernel_pid_t rt_timer_over_pid = KERNEL_PID_UNDEF; bool ack_received; uint8_t dao_counter; diff --git a/sys/net/transport_layer/destiny/tcp.c b/sys/net/transport_layer/destiny/tcp.c index 33d4aa0890..e28ba3edbe 100644 --- a/sys/net/transport_layer/destiny/tcp.c +++ b/sys/net/transport_layer/destiny/tcp.c @@ -122,7 +122,7 @@ void handle_tcp_ack_packet(ipv6_hdr_t *ipv6_header, tcp_hdr_t *tcp_header, socket_internal_t *tcp_socket) { msg_t m_recv_tcp, m_send_tcp; - kernel_pid_t target_pid; + kernel_pid_t target_pid = KERNEL_PID_UNDEF; if (tcp_socket->socket_values.tcp_control.state == TCP_LAST_ACK) { target_pid = tcp_socket->recv_pid; diff --git a/sys/posix/pthread/pthread.c b/sys/posix/pthread/pthread.c index 184a83c492..5e9ea3961f 100644 --- a/sys/posix/pthread/pthread.c +++ b/sys/posix/pthread/pthread.c @@ -54,7 +54,7 @@ enum pthread_thread_status { }; typedef struct pthread_thread { - kernel_pid_t thread_pid; + kernel_pid_t thread_pid = KERNEL_PID_UNDEF; enum pthread_thread_status status; int joining_thread; @@ -132,9 +132,9 @@ int pthread_create(pthread_t *newthread, const pthread_attr_t *attr, void *(*sta void *stack = autofree ? malloc(stack_size) : attr->ss_sp; pt->stack = autofree ? stack : NULL; - if (autofree && pthread_reaper_pid < 0) { + if (autofree && pthread_reaper_pid != KERNEL_PID_UNDEF) { mutex_lock(&pthread_mutex); - if (pthread_reaper_pid < 0) { + if (pthread_reaper_pid != KERNEL_PID_UNDEF) { /* volatile pid to overcome problems with double checking */ volatile kernel_pid_t pid = thread_create(pthread_reaper_stack, PTHREAD_REAPER_STACKSIZE, diff --git a/sys/uart0/uart0.c b/sys/uart0/uart0.c index 5c36f6541c..7adb0d2e06 100644 --- a/sys/uart0/uart0.c +++ b/sys/uart0/uart0.c @@ -39,7 +39,7 @@ #define UART0_STACKSIZE (KERNEL_CONF_STACKSIZE_DEFAULT) ringbuffer_t uart0_ringbuffer; -kernel_pid_t uart0_handler_pid; +kernel_pid_t uart0_handler_pid = KERNEL_PID_UNDEF; static char buffer[UART0_BUFSIZE]; diff --git a/tests/nativenet/main.c b/tests/nativenet/main.c index 0688b94853..730e37b155 100644 --- a/tests/nativenet/main.c +++ b/tests/nativenet/main.c @@ -130,7 +130,7 @@ void sender(void) int main(void) { #ifndef SENDER - kernel_pid_t radio_pid; + kernel_pid_t radio_pid = KERNEL_PID_UNDEF; #endif int16_t a; msg_t mesg; diff --git a/tests/posix_semaphore/main.c b/tests/posix_semaphore/main.c index a59026b161..236c43c97d 100644 --- a/tests/posix_semaphore/main.c +++ b/tests/posix_semaphore/main.c @@ -149,7 +149,7 @@ void test2(void) NULL, names[i]); - if (pid < 0) { + if (pid == KERNEL_PID_UNDEF) { puts("first: thread create failed"); } diff --git a/tests/queue_fairness/main.c b/tests/queue_fairness/main.c index 5f72768ecc..40d864a504 100644 --- a/tests/queue_fairness/main.c +++ b/tests/queue_fairness/main.c @@ -31,7 +31,7 @@ static char stacks[NUM_CHILDREN][STACK_SIZE]; static kernel_pid_t pids[NUM_CHILDREN]; static char names[NUM_CHILDREN][8]; -static kernel_pid_t parent_pid; +static kernel_pid_t parent_pid = KERNEL_PID_UNDEF; static void *child_fun(void *arg) { diff --git a/tests/thread_cooperation/main.c b/tests/thread_cooperation/main.c index 5792a6c2b1..f5097027a5 100644 --- a/tests/thread_cooperation/main.c +++ b/tests/thread_cooperation/main.c @@ -29,7 +29,7 @@ mutex_t mtx = MUTEX_INIT; volatile int storage = 1; -kernel_pid_t main_id; +kernel_pid_t main_id = KERNEL_PID_UNDEF; kernel_pid_t ths[PROBLEM]; char stacks[PROBLEM][KERNEL_CONF_STACKSIZE_MAIN]; diff --git a/tests/thread_msg_block_w_queue/main.c b/tests/thread_msg_block_w_queue/main.c index 0c52bcb13b..f322324410 100644 --- a/tests/thread_msg_block_w_queue/main.c +++ b/tests/thread_msg_block_w_queue/main.c @@ -27,7 +27,7 @@ char t1_stack[KERNEL_CONF_STACKSIZE_MAIN]; -kernel_pid_t p1, p_main; +kernel_pid_t p1 = KERNEL_PID_UNDEF, p_main = KERNEL_PID_UNDEF; void *thread1(void *arg) { diff --git a/tests/thread_msg_block_wo_queue/main.c b/tests/thread_msg_block_wo_queue/main.c index a45d9212db..21f946ed9d 100644 --- a/tests/thread_msg_block_wo_queue/main.c +++ b/tests/thread_msg_block_wo_queue/main.c @@ -27,7 +27,7 @@ char t1_stack[KERNEL_CONF_STACKSIZE_MAIN]; -kernel_pid_t p1, p_main; +kernel_pid_t p1 = KERNEL_PID_UNDEF, p_main = KERNEL_PID_UNDEF; void *thread1(void *arg) { diff --git a/tests/thread_msg_seq/main.c b/tests/thread_msg_seq/main.c index 7e6a725627..9b6606ac48 100644 --- a/tests/thread_msg_seq/main.c +++ b/tests/thread_msg_seq/main.c @@ -29,7 +29,7 @@ char t1_stack[KERNEL_CONF_STACKSIZE_MAIN]; char t2_stack[KERNEL_CONF_STACKSIZE_MAIN]; char t3_stack[KERNEL_CONF_STACKSIZE_MAIN]; -kernel_pid_t p1, p2, p3; +kernel_pid_t p1 = KERNEL_PID_UNDEF, p2 = KERNEL_PID_UNDEF, p3 = KERNEL_PID_UNDEF; void *sub_thread(void *arg) {