Skip to content

Commit

Permalink
Fix wait loop and void cast (#24)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
xiaoxiang781216 authored and gregory-nutt committed Jan 2, 2020
1 parent 316675f commit 6a3c2ad
Show file tree
Hide file tree
Showing 1,602 changed files with 6,302 additions and 10,865 deletions.
4 changes: 2 additions & 2 deletions arch/arm/src/a1x/a1x_irq.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ void up_irqinitialize(void)
{
putreg32(0x00000000, A1X_INTC_EN(i)); /* 0 disables corresponding interrupt */
putreg32(0xffffffff, A1X_INTC_MASK(i)); /* 1 masks corresponding interrupt */
(void)getreg32(A1X_INTC_IRQ_PEND(i)); /* Reading status clears pending interrupts */
getreg32(A1X_INTC_IRQ_PEND(i)); /* Reading status clears pending interrupts */
}

/* Set the interrupt base address to zero. We do not use the vectored
Expand All @@ -178,7 +178,7 @@ void up_irqinitialize(void)

/* And finally, enable interrupts */

(void)up_irq_enable();
up_irq_enable();
#endif

a1x_dumpintc("initial", 0);
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/src/a1x/a1x_pio.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ static int a1x_pio_interrupt(int irq, void *context)
{
/* Yes.. dispatch the interrupt */

(void)arm_doirq(irq, regs);
arm_doirq(irq, regs);
}

irq++;
Expand Down
18 changes: 9 additions & 9 deletions arch/arm/src/a1x/a1x_serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -1528,31 +1528,31 @@ void up_earlyserialinit(void)
void up_serialinit(void)
{
#ifdef CONSOLE_DEV
(void)uart_register("/dev/console", &CONSOLE_DEV);
uart_register("/dev/console", &CONSOLE_DEV);
#endif
#ifdef TTYS0_DEV
(void)uart_register("/dev/ttyS0", &TTYS0_DEV);
uart_register("/dev/ttyS0", &TTYS0_DEV);
#endif
#ifdef TTYS1_DEV
(void)uart_register("/dev/ttyS1", &TTYS1_DEV);
uart_register("/dev/ttyS1", &TTYS1_DEV);
#endif
#ifdef TTYS2_DEV
(void)uart_register("/dev/ttyS2", &TTYS2_DEV);
uart_register("/dev/ttyS2", &TTYS2_DEV);
#endif
#ifdef TTYS3_DEV
(void)uart_register("/dev/ttyS3", &TTYS3_DEV);
uart_register("/dev/ttyS3", &TTYS3_DEV);
#endif
#ifdef TTYS4_DEV
(void)uart_register("/dev/ttyS4", &TTYS4_DEV);
uart_register("/dev/ttyS4", &TTYS4_DEV);
#endif
#ifdef TTYS5_DEV
(void)uart_register("/dev/ttyS5", &TTYS5_DEV);
uart_register("/dev/ttyS5", &TTYS5_DEV);
#endif
#ifdef TTYS6_DEV
(void)uart_register("/dev/ttyS6", &TTYS6_DEV);
uart_register("/dev/ttyS6", &TTYS6_DEV);
#endif
#ifdef TTYS7_DEV
(void)uart_register("/dev/ttyS7", &TTYS7_DEV);
uart_register("/dev/ttyS7", &TTYS7_DEV);
#endif
}

Expand Down
2 changes: 1 addition & 1 deletion arch/arm/src/a1x/a1x_timerisr.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ void arm_timer_initialize(void)

/* Attach the timer interrupt vector */

(void)irq_attach(A1X_IRQ_TIMER0, (xcpt_t)a1x_timerisr, NULL);
irq_attach(A1X_IRQ_TIMER0, (xcpt_t)a1x_timerisr, NULL);

/* Enable interrupts from the TIMER 0 port */

Expand Down
8 changes: 4 additions & 4 deletions arch/arm/src/am335x/am335x_gpioirq.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ void am335x_gpio_irqinitialize(void)

/* Attach and enable the GPIO0 IRQ */

(void)irq_attach(AM335X_IRQ_GPIO0A, am335x_gpio0_interrupt, NULL);
irq_attach(AM335X_IRQ_GPIO0A, am335x_gpio0_interrupt, NULL);
up_enable_irq(AM335X_IRQ_GPIO0A);
#endif

Expand All @@ -284,7 +284,7 @@ void am335x_gpio_irqinitialize(void)

/* Attach and enable the GPIO1 IRQ */

(void)irq_attach(AM335X_IRQ_GPIO1A, am335x_gpio1_interrupt, NULL);
irq_attach(AM335X_IRQ_GPIO1A, am335x_gpio1_interrupt, NULL);
up_enable_irq(AM335X_IRQ_GPIO1A);
#endif

Expand All @@ -309,7 +309,7 @@ void am335x_gpio_irqinitialize(void)

/* Attach and enable the GPIO2 IRQ */

(void)irq_attach(AM335X_IRQ_GPIO2A, am335x_gpio2_interrupt, NULL);
irq_attach(AM335X_IRQ_GPIO2A, am335x_gpio2_interrupt, NULL);
up_enable_irq(AM335X_IRQ_GPIO2A);
#endif

Expand All @@ -334,7 +334,7 @@ void am335x_gpio_irqinitialize(void)

/* Attach and enable the GPIO3 IRQ */

(void)irq_attach(AM335X_IRQ_GPIO3A, am335x_gpio3_interrupt, NULL);
irq_attach(AM335X_IRQ_GPIO3A, am335x_gpio3_interrupt, NULL);
up_enable_irq(AM335X_IRQ_GPIO3A);
#endif
}
Expand Down
6 changes: 3 additions & 3 deletions arch/arm/src/am335x/am335x_irq.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ void up_irqinitialize(void)
for (i = 0; i < AM335X_IRQ_NINT; i += 32)
{
putreg32(0xffffffff, AM335X_INTC_MIR_SET(i)); /* 1 masks corresponding interrupt */
(void)getreg32(AM335X_INTC_PEND_IRQ(i)); /* Reading status clears pending interrupts */
(void)getreg32(AM335X_INTC_PEND_FIQ(i)); /* Reading status clears pending interrupts */
getreg32(AM335X_INTC_PEND_IRQ(i)); /* Reading status clears pending interrupts */
getreg32(AM335X_INTC_PEND_FIQ(i)); /* Reading status clears pending interrupts */
}

/* currents_regs is non-NULL only while processing an interrupt */
Expand All @@ -150,7 +150,7 @@ void up_irqinitialize(void)

/* And finally, enable interrupts */

(void)up_irq_enable();
up_irq_enable();
#endif
}

Expand Down
2 changes: 1 addition & 1 deletion arch/arm/src/am335x/am335x_lcdc.c
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ int am335x_lcd_initialize(FAR const struct am335x_panel_info_s *panel)

/* Initialize the device state singleton */

sem_init(&priv->exclsem, 0, 1);
nxsem_init(&priv->exclsem, 0, 1);
memcpy(&priv->panel, panel, sizeof(struct am335x_panel_info_s));

/* Save framebuffer information */
Expand Down
14 changes: 7 additions & 7 deletions arch/arm/src/am335x/am335x_serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -1347,25 +1347,25 @@ void up_earlyserialinit(void)
void up_serialinit(void)
{
#ifdef CONSOLE_DEV
(void)uart_register("/dev/console", &CONSOLE_DEV);
uart_register("/dev/console", &CONSOLE_DEV);
#endif
#ifdef TTYS0_DEV
(void)uart_register("/dev/ttyS0", &TTYS0_DEV);
uart_register("/dev/ttyS0", &TTYS0_DEV);
#endif
#ifdef TTYS1_DEV
(void)uart_register("/dev/ttyS1", &TTYS1_DEV);
uart_register("/dev/ttyS1", &TTYS1_DEV);
#endif
#ifdef TTYS2_DEV
(void)uart_register("/dev/ttyS2", &TTYS2_DEV);
uart_register("/dev/ttyS2", &TTYS2_DEV);
#endif
#ifdef TTYS3_DEV
(void)uart_register("/dev/ttyS3", &TTYS3_DEV);
uart_register("/dev/ttyS3", &TTYS3_DEV);
#endif
#ifdef TTYS4_DEV
(void)uart_register("/dev/ttyS4", &TTYS4_DEV);
uart_register("/dev/ttyS4", &TTYS4_DEV);
#endif
#ifdef TTYS5_DEV
(void)uart_register("/dev/ttyS5", &TTYS5_DEV);
uart_register("/dev/ttyS5", &TTYS5_DEV);
#endif
}

Expand Down
4 changes: 2 additions & 2 deletions arch/arm/src/am335x/am335x_timerisr.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ void arm_timer_initialize(void)

/* Attach the timer interrupt vector */

(void)irq_attach(AM335X_IRQ_TIMER1_1MS, (xcpt_t)am335x_timerisr, NULL);
irq_attach(AM335X_IRQ_TIMER1_1MS, (xcpt_t)am335x_timerisr, NULL);

/* Clear interrupt status */

Expand Down Expand Up @@ -193,7 +193,7 @@ void arm_timer_initialize(void)

/* Attach the timer interrupt vector */

(void)irq_attach(AM335X_IRQ_TIMER2, (xcpt_t)am335x_timerisr, NULL);
irq_attach(AM335X_IRQ_TIMER2, (xcpt_t)am335x_timerisr, NULL);

/* Enable overflow interrupt */

Expand Down
10 changes: 5 additions & 5 deletions arch/arm/src/arm/up_assert.c
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ static void up_dumpstate(void)
#ifdef CONFIG_ARCH_USBDUMP
/* Dump USB trace data */

(void)usbtrace_enumerate(assert_tracecallback, NULL);
usbtrace_enumerate(assert_tracecallback, NULL);
#endif
}
#else
Expand All @@ -306,13 +306,13 @@ 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? */

if (CURRENT_REGS || running_task()->flink == NULL)
{
(void)up_irq_save();
up_irq_save();
for (; ; )
{
#if CONFIG_BOARD_RESET_ON_ASSERT >= 1
Expand Down Expand Up @@ -353,7 +353,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",
Expand All @@ -367,7 +367,7 @@ void up_assert(const uint8_t *filename, int lineno)

/* 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);
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/src/arm/up_blocktask.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,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(rtcb);
group_addrenv(rtcb);
#endif
/* Reset scheduler parameters */

Expand Down
2 changes: 1 addition & 1 deletion arch/arm/src/arm/up_doirq.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ void up_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
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/src/arm/up_releasepending.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ void up_release_pending(void)
* thread at the head of the ready-to-run list.
*/

(void)group_addrenv(rtcb);
group_addrenv(rtcb);
#endif
/* Update scheduler parameters */

Expand Down
2 changes: 1 addition & 1 deletion arch/arm/src/arm/up_reprioritizertr.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,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(rtcb);
group_addrenv(rtcb);
#endif
/* Update scheduler parameters */

Expand Down
2 changes: 1 addition & 1 deletion arch/arm/src/arm/up_sigdeliver.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ void up_sigdeliver(void)
*/

sinfo("Resuming\n");
(void)up_irq_save();
up_irq_save();
rtcb->pterrno = saved_errno;

/* Modify the saved return state with the actual saved values in the
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/src/arm/up_unblocktask.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ void up_unblock_task(struct tcb_s *tcb)
* thread at the head of the ready-to-run list.
*/

(void)group_addrenv(rtcb);
group_addrenv(rtcb);
#endif
/* Update scheduler parameters */

Expand Down
10 changes: 5 additions & 5 deletions arch/arm/src/armv6-m/up_assert.c
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ static void up_dumpstate(void)
#ifdef CONFIG_ARCH_USBDUMP
/* Dump USB trace data */

(void)usbtrace_enumerate(assert_tracecallback, NULL);
usbtrace_enumerate(assert_tracecallback, NULL);
#endif
}
#else
Expand All @@ -363,13 +363,13 @@ 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? */

if (CURRENT_REGS || running_task()->flink == NULL)
{
(void)up_irq_save();
up_irq_save();
for (; ; )
{
#if CONFIG_BOARD_RESET_ON_ASSERT >= 1
Expand Down Expand Up @@ -410,7 +410,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",
Expand All @@ -424,7 +424,7 @@ void up_assert(const uint8_t *filename, int lineno)

/* 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);
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/src/armv6-m/up_hardfault.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ int up_hardfault(int irq, FAR void *context, FAR void *arg)
getprimask(), getipsr());
#endif

(void)up_irq_save();
up_irq_save();
hfalert("PANIC!!! Hard fault\n");
PANIC();
return OK; /* Won't get here */
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/src/armv6-m/up_sigdeliver.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ void up_sigdeliver(void)
*/

sinfo("Resuming\n");
(void)up_irq_save();
up_irq_save();
rtcb->pterrno = saved_errno;

/* Modify the saved return state with the actual saved values in the
Expand Down
4 changes: 2 additions & 2 deletions arch/arm/src/armv6-m/up_signal_dispatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ void up_signal_dispatch(_sa_sigaction_t sighand, int signo,
{
/* Let sys_call4() do all of the work */

(void)sys_call4(SYS_signal_handler, (uintptr_t)sighand, (uintptr_t)signo,
(uintptr_t)info, (uintptr_t)ucontext);
sys_call4(SYS_signal_handler, (uintptr_t)sighand, (uintptr_t)signo,
(uintptr_t)info, (uintptr_t)ucontext);
}

#endif /* (CONFIG_BUILD_PROTECTED || CONFIG_BUILD_KERNEL) && !CONFIG_DISABLE_PTHREAD */
Loading

0 comments on commit 6a3c2ad

Please sign in to comment.