mirror of
https://github.com/apache/nuttx.git
synced 2026-05-31 14:27:37 +08:00
Fix wait loop and void cast (#24)
* Simplify EINTR/ECANCEL error handling 1. Add semaphore uninterruptible wait function 2 .Replace semaphore wait loop with a single uninterruptible wait 3. Replace all sem_xxx to nxsem_xxx * Unify the void cast usage 1. Remove void cast for function because many place ignore the returned value witout cast 2. Replace void cast for variable with UNUSED macro
This commit is contained in:
@@ -87,7 +87,7 @@
|
||||
|
||||
#define SYS_restore_context (1)
|
||||
#define up_fullcontextrestore(restoreregs) \
|
||||
(void)sys_call1(SYS_restore_context, (uintptr_t)restoreregs)
|
||||
sys_call1(SYS_restore_context, (uintptr_t)restoreregs)
|
||||
|
||||
/* SYS call 2:
|
||||
*
|
||||
@@ -96,7 +96,7 @@
|
||||
|
||||
#define SYS_switch_context (2)
|
||||
#define up_switchcontext(saveregs, restoreregs) \
|
||||
(void)sys_call2(SYS_switch_context, (uintptr_t)saveregs, (uintptr_t)restoreregs)
|
||||
sys_call2(SYS_switch_context, (uintptr_t)saveregs, (uintptr_t)restoreregs)
|
||||
|
||||
#ifdef CONFIG_BUILD_KERNEL
|
||||
/* SYS call 3:
|
||||
|
||||
@@ -88,7 +88,7 @@
|
||||
|
||||
#define SYS_restore_context (1)
|
||||
#define up_fullcontextrestore(restoreregs) \
|
||||
(void)sys_call1(SYS_restore_context, (uintptr_t)restoreregs)
|
||||
sys_call1(SYS_restore_context, (uintptr_t)restoreregs)
|
||||
|
||||
/* SYS call 2:
|
||||
*
|
||||
@@ -97,8 +97,8 @@
|
||||
|
||||
#define SYS_switch_context (2)
|
||||
#define up_switchcontext(saveregs, restoreregs) \
|
||||
(void)sys_call2(SYS_switch_context, (uintptr_t)saveregs, \
|
||||
(uintptr_t)restoreregs)
|
||||
sys_call2(SYS_switch_context, (uintptr_t)saveregs, \
|
||||
(uintptr_t)restoreregs)
|
||||
|
||||
#ifdef CONFIG_BUILD_KERNEL
|
||||
|
||||
|
||||
@@ -269,8 +269,8 @@ static int misoc_net_transmit(FAR struct misoc_net_driver_s *priv)
|
||||
|
||||
/* Setup the TX timeout watchdog (perhaps restarting the timer) */
|
||||
|
||||
(void)wd_start(priv->misoc_net_txtimeout, MISOC_NET_TXTIMEOUT,
|
||||
misoc_net_txtimeout_expiry, 1, (wdparm_t)priv);
|
||||
wd_start(priv->misoc_net_txtimeout, MISOC_NET_TXTIMEOUT,
|
||||
misoc_net_txtimeout_expiry, 1, (wdparm_t)priv);
|
||||
return OK;
|
||||
}
|
||||
|
||||
@@ -561,7 +561,7 @@ static void misoc_net_txdone(FAR struct misoc_net_driver_s *priv)
|
||||
|
||||
/* In any event, poll the network for new TX data */
|
||||
|
||||
(void)devif_poll(&priv->misoc_net_dev, misoc_net_txpoll);
|
||||
devif_poll(&priv->misoc_net_dev, misoc_net_txpoll);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -694,7 +694,7 @@ static void misoc_net_txtimeout_work(FAR void *arg)
|
||||
|
||||
/* Then poll the network for new XMIT data */
|
||||
|
||||
(void)devif_poll(&priv->misoc_net_dev, misoc_net_txpoll);
|
||||
devif_poll(&priv->misoc_net_dev, misoc_net_txpoll);
|
||||
net_unlock();
|
||||
}
|
||||
|
||||
@@ -769,12 +769,12 @@ static void misoc_net_poll_work(FAR void *arg)
|
||||
* progress, we will missing TCP time state updates?
|
||||
*/
|
||||
|
||||
(void)devif_timer(&priv->misoc_net_dev, MISOC_NET_WDDELAY, misoc_net_txpoll);
|
||||
devif_timer(&priv->misoc_net_dev, MISOC_NET_WDDELAY, misoc_net_txpoll);
|
||||
|
||||
/* Setup the watchdog poll timer again */
|
||||
|
||||
(void)wd_start(priv->misoc_net_txpoll, MISOC_NET_WDDELAY, misoc_net_poll_expiry, 1,
|
||||
(wdparm_t)priv);
|
||||
wd_start(priv->misoc_net_txpoll, MISOC_NET_WDDELAY, misoc_net_poll_expiry, 1,
|
||||
(wdparm_t)priv);
|
||||
|
||||
net_unlock();
|
||||
}
|
||||
@@ -855,8 +855,8 @@ static int misoc_net_ifup(FAR struct net_driver_s *dev)
|
||||
|
||||
/* Set and activate a timer process */
|
||||
|
||||
(void)wd_start(priv->misoc_net_txpoll, MISOC_NET_WDDELAY,
|
||||
misoc_net_poll_expiry, 1, (wdparm_t)priv);
|
||||
wd_start(priv->misoc_net_txpoll, MISOC_NET_WDDELAY,
|
||||
misoc_net_poll_expiry, 1, (wdparm_t)priv);
|
||||
|
||||
priv->misoc_net_bifup = true;
|
||||
up_enable_irq(ETHMAC_INTERRUPT);
|
||||
@@ -948,7 +948,7 @@ static void misoc_net_txavail_work(FAR void *arg)
|
||||
{
|
||||
/* If so, then poll the network for new XMIT data */
|
||||
|
||||
(void)devif_poll(&priv->misoc_net_dev, misoc_net_txpoll);
|
||||
devif_poll(&priv->misoc_net_dev, misoc_net_txpoll);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1104,7 +1104,7 @@ static void misoc_net_ipv6multicast(FAR struct misoc_net_driver_s *priv)
|
||||
ninfo("IPv6 Multicast: %02x:%02x:%02x:%02x:%02x:%02x\n",
|
||||
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
|
||||
|
||||
(void)misoc_net_addmac(dev, mac);
|
||||
misoc_net_addmac(dev, mac);
|
||||
|
||||
#ifdef CONFIG_NET_ICMPv6_AUTOCONF
|
||||
/* Add the IPv6 all link-local nodes Ethernet address. This is the
|
||||
@@ -1112,7 +1112,7 @@ static void misoc_net_ipv6multicast(FAR struct misoc_net_driver_s *priv)
|
||||
* packets.
|
||||
*/
|
||||
|
||||
(void)misoc_net_addmac(dev, g_ipv6_ethallnodes.ether_addr_octet);
|
||||
misoc_net_addmac(dev, g_ipv6_ethallnodes.ether_addr_octet);
|
||||
|
||||
#endif /* CONFIG_NET_ICMPv6_AUTOCONF */
|
||||
#ifdef CONFIG_NET_ICMPv6_ROUTER
|
||||
@@ -1121,7 +1121,7 @@ static void misoc_net_ipv6multicast(FAR struct misoc_net_driver_s *priv)
|
||||
* packets.
|
||||
*/
|
||||
|
||||
(void)misoc_net_addmac(dev, g_ipv6_ethallrouters.ether_addr_octet);
|
||||
misoc_net_addmac(dev, g_ipv6_ethallrouters.ether_addr_octet);
|
||||
|
||||
#endif /* CONFIG_NET_ICMPv6_ROUTER */
|
||||
}
|
||||
@@ -1208,7 +1208,7 @@ int misoc_net_initialize(int intf)
|
||||
|
||||
/* Register the device with the OS so that socket IOCTLs can be performed */
|
||||
|
||||
(void)netdev_register(&priv->misoc_net_dev, NET_LL_ETHERNET);
|
||||
netdev_register(&priv->misoc_net_dev, NET_LL_ETHERNET);
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -313,7 +313,7 @@ static int misoc_attach(struct uart_dev_s *dev)
|
||||
{
|
||||
struct misoc_dev_s *priv = (struct misoc_dev_s *)dev->priv;
|
||||
|
||||
(void)irq_attach(priv->irq, misoc_uart_interrupt, dev);
|
||||
irq_attach(priv->irq, misoc_uart_interrupt, dev);
|
||||
up_enable_irq(priv->irq);
|
||||
|
||||
return OK;
|
||||
@@ -656,10 +656,10 @@ void misoc_serial_initialize(void)
|
||||
/* Register the console */
|
||||
|
||||
#ifdef HAVE_SERIAL_CONSOLE
|
||||
(void)uart_register("/dev/console", &CONSOLE_DEV);
|
||||
uart_register("/dev/console", &CONSOLE_DEV);
|
||||
#endif
|
||||
|
||||
/* Register all UARTs */
|
||||
(void)uart_register("/dev/ttyS0", &TTYS0_DEV);
|
||||
uart_register("/dev/ttyS0", &TTYS0_DEV);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ void misoc_timer_initialize(void)
|
||||
|
||||
/* Attach the timer interrupt vector */
|
||||
|
||||
(void)irq_attach(TIMER0_INTERRUPT, misoc_timer_isr, NULL);
|
||||
irq_attach(TIMER0_INTERRUPT, misoc_timer_isr, NULL);
|
||||
|
||||
/* And enable the timer interrupt */
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ static void _up_assert(int errorcode)
|
||||
{
|
||||
/* Flush any buffered SYSLOG data */
|
||||
|
||||
(void)syslog_flush();
|
||||
syslog_flush();
|
||||
|
||||
/* Are we in an interrupt handler or the idle task?
|
||||
* NOTE: You cannot use the PID to determine if this is an IDLE task. In
|
||||
@@ -94,7 +94,7 @@ static void _up_assert(int errorcode)
|
||||
|
||||
if (g_current_regs || running_task()->flink == NULL)
|
||||
{
|
||||
(void)up_irq_save();
|
||||
up_irq_save();
|
||||
for (; ; )
|
||||
{
|
||||
#if CONFIG_BOARD_RESET_ON_ASSERT >= 1
|
||||
@@ -160,7 +160,7 @@ void up_assert(const uint8_t *filename, int lineno)
|
||||
|
||||
/* Flush any buffered SYSLOG data (prior to the assertion) */
|
||||
|
||||
(void)syslog_flush();
|
||||
syslog_flush();
|
||||
|
||||
#if CONFIG_TASK_NAME_SIZE > 0
|
||||
_alert("Assertion failed at file:%s line: %d task: %s\n",
|
||||
@@ -175,12 +175,12 @@ void up_assert(const uint8_t *filename, int lineno)
|
||||
#ifdef CONFIG_ARCH_USBDUMP
|
||||
/* Dump USB trace data */
|
||||
|
||||
(void)usbtrace_enumerate(assert_tracecallback, NULL);
|
||||
usbtrace_enumerate(assert_tracecallback, NULL);
|
||||
#endif
|
||||
|
||||
/* Flush any buffered SYSLOG data (from the above) */
|
||||
|
||||
(void)syslog_flush();
|
||||
syslog_flush();
|
||||
|
||||
#ifdef CONFIG_BOARD_CRASHDUMP
|
||||
board_crashdump(up_getsp(), running_task(), filename, lineno);
|
||||
|
||||
@@ -160,7 +160,7 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state)
|
||||
* thread at the head of the ready-to-run list.
|
||||
*/
|
||||
|
||||
(void)group_addrenv(nexttcb);
|
||||
group_addrenv(nexttcb);
|
||||
#endif
|
||||
/* Reset scheduler parameters */
|
||||
|
||||
|
||||
@@ -104,7 +104,7 @@ uint32_t *lm32_doirq(int irq, uint32_t *regs)
|
||||
* thread at the head of the ready-to-run list.
|
||||
*/
|
||||
|
||||
(void)group_addrenv(NULL);
|
||||
group_addrenv(NULL);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -142,7 +142,7 @@ void _exit(int status)
|
||||
* The IRQ state will be restored when the next task is started.
|
||||
*/
|
||||
|
||||
(void)enter_critical_section();
|
||||
enter_critical_section();
|
||||
|
||||
sinfo("TCB=%p exiting\n", tcb);
|
||||
|
||||
@@ -157,7 +157,7 @@ void _exit(int status)
|
||||
|
||||
/* Destroy the task at the head of the ready to run list. */
|
||||
|
||||
(void)nxtask_exit();
|
||||
nxtask_exit();
|
||||
|
||||
/* Now, perform the context switch to the new ready-to-run task at the
|
||||
* head of the list.
|
||||
@@ -172,7 +172,7 @@ void _exit(int status)
|
||||
* the ready-to-run list.
|
||||
*/
|
||||
|
||||
(void)group_addrenv(tcb);
|
||||
group_addrenv(tcb);
|
||||
#endif
|
||||
|
||||
/* Reset scheduler parameters */
|
||||
|
||||
@@ -71,7 +71,7 @@ void lm32_irq_initialize(void)
|
||||
|
||||
/* Attach the software interrupt */
|
||||
|
||||
(void)irq_attach(LM32_IRQ_SWINT, lm32_swint, NULL);
|
||||
irq_attach(LM32_IRQ_SWINT, lm32_swint, NULL);
|
||||
|
||||
/* Enable interrupts */
|
||||
|
||||
|
||||
@@ -129,7 +129,7 @@ void up_release_pending(void)
|
||||
* thread at the head of the ready-to-run list.
|
||||
*/
|
||||
|
||||
(void)group_addrenv(nexttcb);
|
||||
group_addrenv(nexttcb);
|
||||
#endif
|
||||
/* Update scheduler parameters */
|
||||
|
||||
|
||||
@@ -182,7 +182,7 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority)
|
||||
* thread at the head of the ready-to-run list.
|
||||
*/
|
||||
|
||||
(void)group_addrenv(nexttcb);
|
||||
group_addrenv(nexttcb);
|
||||
#endif
|
||||
/* Update scheduler parameters */
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ void lm32_sigdeliver(void)
|
||||
|
||||
sinfo("Resuming EPC: %08x INT_CTX: %08x\n", regs[REG_EPC], regs[REG_INT_CTX]);
|
||||
|
||||
(void)up_irq_save();
|
||||
up_irq_save();
|
||||
rtcb->pterrno = saved_errno;
|
||||
|
||||
/* Modify the saved return state with the actual saved values in the
|
||||
|
||||
@@ -320,7 +320,7 @@ int lm32_swint(int irq, FAR void *context, FAR void *arg)
|
||||
* thread at the head of the ready-to-run list.
|
||||
*/
|
||||
|
||||
(void)group_addrenv(NULL);
|
||||
group_addrenv(NULL);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -144,7 +144,7 @@ void up_unblock_task(struct tcb_s *tcb)
|
||||
* thread at the head of the ready-to-run list.
|
||||
*/
|
||||
|
||||
(void)group_addrenv(nexttcb);
|
||||
group_addrenv(nexttcb);
|
||||
#endif
|
||||
/* Update scheduler parameters */
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ static void _up_assert(int errorcode)
|
||||
{
|
||||
/* Flush any buffered SYSLOG data */
|
||||
|
||||
(void)syslog_flush();
|
||||
syslog_flush();
|
||||
|
||||
/* Are we in an interrupt handler or the idle task? NOTE: You cannot use the
|
||||
* PID to determine if this is an IDLE task. In the SMP case, there may be
|
||||
@@ -94,7 +94,7 @@ static void _up_assert(int errorcode)
|
||||
|
||||
if (g_current_regs || running_task()->flink == NULL)
|
||||
{
|
||||
(void)up_irq_save();
|
||||
up_irq_save();
|
||||
for (; ; )
|
||||
{
|
||||
#if CONFIG_BOARD_RESET_ON_ASSERT >= 1
|
||||
@@ -160,7 +160,7 @@ void up_assert(const uint8_t * filename, int lineno)
|
||||
|
||||
/* Flush any buffered SYSLOG data (prior to the assertion) */
|
||||
|
||||
(void)syslog_flush();
|
||||
syslog_flush();
|
||||
|
||||
#if CONFIG_TASK_NAME_SIZE > 0
|
||||
_alert("Assertion failed at file:%s line: %d task: %s\n",
|
||||
@@ -174,12 +174,12 @@ void up_assert(const uint8_t * filename, int lineno)
|
||||
#ifdef CONFIG_ARCH_USBDUMP
|
||||
/* Dump USB trace data */
|
||||
|
||||
(void)usbtrace_enumerate(assert_tracecallback, NULL);
|
||||
usbtrace_enumerate(assert_tracecallback, NULL);
|
||||
#endif
|
||||
|
||||
/* Flush any buffered SYSLOG data (from the above) */
|
||||
|
||||
(void)syslog_flush();
|
||||
syslog_flush();
|
||||
|
||||
#ifdef CONFIG_BOARD_CRASHDUMP
|
||||
board_crashdump(up_getsp(), running_task(), filename, lineno);
|
||||
|
||||
@@ -157,7 +157,7 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state)
|
||||
* of the ready-to-run list.
|
||||
*/
|
||||
|
||||
(void)group_addrenv(nexttcb);
|
||||
group_addrenv(nexttcb);
|
||||
#endif
|
||||
/* Reset scheduler parameters */
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ uint32_t *minerva_doirq(int irq, uint32_t * regs)
|
||||
* the ready-to-run list.
|
||||
*/
|
||||
|
||||
(void)group_addrenv(NULL);
|
||||
group_addrenv(NULL);
|
||||
# endif
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -140,7 +140,7 @@ void _exit(int status)
|
||||
* IRQ state will be restored when the next task is started.
|
||||
*/
|
||||
|
||||
(void)enter_critical_section();
|
||||
enter_critical_section();
|
||||
|
||||
sinfo("TCB=%p exiting\n", tcb);
|
||||
|
||||
@@ -155,7 +155,7 @@ void _exit(int status)
|
||||
|
||||
/* Destroy the task at the head of the ready to run list. */
|
||||
|
||||
(void)nxtask_exit();
|
||||
nxtask_exit();
|
||||
|
||||
/* Now, perform the context switch to the new ready-to-run task at the head
|
||||
* of the list.
|
||||
@@ -170,7 +170,7 @@ void _exit(int status)
|
||||
* list.
|
||||
*/
|
||||
|
||||
(void)group_addrenv(tcb);
|
||||
group_addrenv(tcb);
|
||||
#endif
|
||||
|
||||
/* Reset scheduler parameters */
|
||||
|
||||
@@ -71,7 +71,7 @@ void minerva_irq_initialize(void)
|
||||
|
||||
/* Attach the software interrupt */
|
||||
|
||||
(void)irq_attach(MINERVA_IRQ_SWINT, minerva_swint, NULL);
|
||||
irq_attach(MINERVA_IRQ_SWINT, minerva_swint, NULL);
|
||||
|
||||
/* Enable interrupts */
|
||||
|
||||
|
||||
@@ -128,7 +128,7 @@ void up_release_pending(void)
|
||||
* of the ready-to-run list.
|
||||
*/
|
||||
|
||||
(void)group_addrenv(nexttcb);
|
||||
group_addrenv(nexttcb);
|
||||
#endif
|
||||
/* Update scheduler parameters */
|
||||
|
||||
|
||||
@@ -180,7 +180,7 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority)
|
||||
* thread at the head of the ready-to-run list.
|
||||
*/
|
||||
|
||||
(void)group_addrenv(nexttcb);
|
||||
group_addrenv(nexttcb);
|
||||
#endif
|
||||
/* Update scheduler parameters */
|
||||
|
||||
|
||||
@@ -119,7 +119,7 @@ void minerva_sigdeliver(void)
|
||||
sinfo("Resuming EPC: %08x INT_CTX: %08x\n", regs[REG_CSR_MEPC],
|
||||
regs[REG_CSR_MSTATUS]);
|
||||
|
||||
(void)up_irq_save();
|
||||
up_irq_save();
|
||||
rtcb->pterrno = saved_errno;
|
||||
|
||||
/* Then restore the correct state for this thread of execution. */
|
||||
|
||||
@@ -309,7 +309,7 @@ int minerva_swint(int irq, FAR void *context, FAR void *arg)
|
||||
* the ready-to-run list.
|
||||
*/
|
||||
|
||||
(void)group_addrenv(NULL);
|
||||
group_addrenv(NULL);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -144,7 +144,7 @@ void up_unblock_task(struct tcb_s *tcb)
|
||||
* head of the ready-to-run list.
|
||||
*/
|
||||
|
||||
(void)group_addrenv(nexttcb);
|
||||
group_addrenv(nexttcb);
|
||||
#endif
|
||||
/* Update scheduler parameters */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user