From 3a046719122667066be6f7feab8f65cc59c9e4f4 Mon Sep 17 00:00:00 2001 From: Ludwig Ortmann Date: Wed, 20 Nov 2013 15:25:11 +0100 Subject: [PATCH] replace 1 with EXIT_FAILURE in all err calls --- cpu/native/hwtimer_cpu.c | 5 ++-- cpu/native/irq_cpu.c | 50 +++++++++++++++++++------------------- cpu/native/lpm_cpu.c | 2 +- cpu/native/native_cpu.c | 14 +++++------ cpu/native/net/tap.c | 4 +-- cpu/native/rtc/posix-rtc.c | 5 ++-- 6 files changed, 41 insertions(+), 39 deletions(-) diff --git a/cpu/native/hwtimer_cpu.c b/cpu/native/hwtimer_cpu.c index a18fcba817..338d67e7e4 100644 --- a/cpu/native/hwtimer_cpu.c +++ b/cpu/native/hwtimer_cpu.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include "hwtimer.h" @@ -118,7 +119,7 @@ void schedule_timer(void) * are set at all */ if (native_hwtimer_isset[next_timer] == 1) { if (setitimer(ITIMER_REAL, &native_hwtimer[next_timer], NULL) == -1) { - err(1, "schedule_timer"); + err(EXIT_FAILURE, "schedule_timer"); } else { DEBUG("schedule_timer(): set next timer.\n"); @@ -237,7 +238,7 @@ unsigned long hwtimer_arch_now(void) #else if (clock_gettime(CLOCK_MONOTONIC, &t) == -1) { - err(1, "hwtimer_arch_now: clock_gettime"); + err(EXIT_FAILURE, "hwtimer_arch_now: clock_gettime"); } #endif diff --git a/cpu/native/irq_cpu.c b/cpu/native/irq_cpu.c index ba8451bdd9..8b75ced92a 100644 --- a/cpu/native/irq_cpu.c +++ b/cpu/native/irq_cpu.c @@ -74,7 +74,7 @@ void print_thread_sigmask(ucontext_t *cp) sigset_t *p = &cp->uc_sigmask; if (sigemptyset(p) == -1) { - err(1, "print_thread_sigmask: sigemptyset"); + err(EXIT_FAILURE, "print_thread_sigmask: sigemptyset"); } for (int i = 1; i < (NSIG); i++) { @@ -113,15 +113,15 @@ void native_print_signals() puts("native signals:\n"); if (sigemptyset(&p) == -1) { - err(1, "native_print_signals: sigemptyset"); + err(EXIT_FAILURE, "native_print_signals: sigemptyset"); } if (sigpending(&p) == -1) { - err(1, "native_print_signals: sigpending"); + err(EXIT_FAILURE, "native_print_signals: sigpending"); } if (sigprocmask(SIG_SETMASK, NULL, &q) == -1) { - err(1, "native_print_signals(): sigprocmask"); + err(EXIT_FAILURE, "native_print_signals(): sigprocmask"); } for (int i = 1; i < (NSIG); i++) { @@ -158,21 +158,21 @@ unsigned disableIRQ(void) } if (sigfillset(&mask) == -1) { - err(1, "disableIRQ(): sigfillset"); + err(EXIT_FAILURE, "disableIRQ(): sigfillset"); } if (native_interrupts_enabled == 1) { DEBUG("sigprocmask(..native_sig_set)\n"); if (sigprocmask(SIG_SETMASK, &mask, &native_sig_set) == -1) { - err(1, "disableIRQ(): sigprocmask"); + err(EXIT_FAILURE, "disableIRQ(): sigprocmask"); } } else { DEBUG("sigprocmask()\n"); if (sigprocmask(SIG_SETMASK, &mask, NULL) == -1) { - err(1, "disableIRQ(): sigprocmask()"); + err(EXIT_FAILURE, "disableIRQ(): sigprocmask()"); } } @@ -200,7 +200,7 @@ unsigned enableIRQ(void) } if (sigprocmask(SIG_SETMASK, &native_sig_set, NULL) == -1) { - err(1, "enableIRQ(): sigprocmask()"); + err(EXIT_FAILURE, "enableIRQ(): sigprocmask()"); } prev_state = native_interrupts_enabled; @@ -257,7 +257,7 @@ int _native_popsig(void) } if (nread == -1) { - err(1, "_native_popsig(): real_read()"); + err(EXIT_FAILURE, "_native_popsig(): real_read()"); } return sig; @@ -310,7 +310,7 @@ void native_isr_entry(int sig, siginfo_t *info, void *context) /* save the signal */ if (real_write(_sig_pipefd[1], &sig, sizeof(int)) == -1) { - err(1, "native_isr_entry(): real_write()"); + err(EXIT_FAILURE, "native_isr_entry(): real_write()"); } _native_sigpend++; //real_write(STDOUT_FILENO, "sigpend\n", 8); @@ -374,7 +374,7 @@ int register_interrupt(int sig, void (*handler)(void)) DEBUG("XXX: register_interrupt()\n"); if (sigdelset(&native_sig_set, sig)) { - err(1, "register_interrupt: sigdelset"); + err(EXIT_FAILURE, "register_interrupt: sigdelset"); } native_irq_handlers[sig].func = handler; @@ -382,13 +382,13 @@ int register_interrupt(int sig, void (*handler)(void)) sa.sa_sigaction = native_isr_entry; if (sigemptyset(&sa.sa_mask) == -1) { - err(1, "register_interrupt: sigemptyset"); + err(EXIT_FAILURE, "register_interrupt: sigemptyset"); } sa.sa_flags = SA_RESTART | SA_SIGINFO | SA_ONSTACK; if (sigaction(sig, &sa, NULL)) { - err(1, "register_interrupt: sigaction"); + err(EXIT_FAILURE, "register_interrupt: sigaction"); } return 0; @@ -406,7 +406,7 @@ int unregister_interrupt(int sig) DEBUG("XXX: unregister_interrupt()\n"); if (sigaddset(&native_sig_set, sig) == -1) { - err(1, "unregister_interrupt: sigaddset"); + err(EXIT_FAILURE, "unregister_interrupt: sigaddset"); } native_irq_handlers[sig].func = NULL; @@ -414,13 +414,13 @@ int unregister_interrupt(int sig) sa.sa_handler = SIG_IGN; if (sigemptyset(&sa.sa_mask) == -1) { - err(1, "unregister_interrupt: sigemptyset"); + err(EXIT_FAILURE, "unregister_interrupt: sigemptyset"); } sa.sa_flags = SA_RESTART | SA_SIGINFO | SA_ONSTACK; if (sigaction(sig, &sa, NULL)) { - err(1, "unregister_interrupt: sigaction"); + err(EXIT_FAILURE, "unregister_interrupt: sigaction"); } return 0; @@ -461,34 +461,34 @@ void native_interrupt_init(void) sa.sa_sigaction = native_isr_entry; if (sigemptyset(&sa.sa_mask) == -1) { - err(1, "native_interrupt_init: sigemptyset"); + err(EXIT_FAILURE, "native_interrupt_init: sigemptyset"); } sa.sa_flags = SA_RESTART | SA_SIGINFO | SA_ONSTACK; /* if (sigemptyset(&native_sig_set) == -1) { - err(1, "native_interrupt_init: sigemptyset"); + err(EXIT_FAILURE, "native_interrupt_init: sigemptyset"); } */ if (sigprocmask(SIG_SETMASK, NULL, &native_sig_set) == -1) { - err(1, "native_interrupt_init(): sigprocmask"); + err(EXIT_FAILURE, "native_interrupt_init(): sigprocmask"); } if (sigdelset(&native_sig_set, SIGUSR1) == -1) { - err(1, "native_interrupt_init: sigdelset"); + err(EXIT_FAILURE, "native_interrupt_init: sigdelset"); } if (sigaction(SIGUSR1, &sa, NULL)) { - err(1, "native_interrupt_init: sigaction"); + err(EXIT_FAILURE, "native_interrupt_init: sigaction"); } if (getcontext(&native_isr_context) == -1) { - err(1, "native_isr_entry(): getcontext()"); + err(EXIT_FAILURE, "native_isr_entry(): getcontext()"); } if (sigfillset(&(native_isr_context.uc_sigmask)) == -1) { - err(1, "native_isr_entry(): sigfillset()"); + err(EXIT_FAILURE, "native_isr_entry(): sigfillset()"); } native_isr_context.uc_stack.ss_sp = __isr_stack; @@ -502,7 +502,7 @@ void native_interrupt_init(void) sigstk.ss_flags = 0; if (sigaltstack(&sigstk, NULL) < 0) { - err(1, "main: sigaltstack"); + err(EXIT_FAILURE, "main: sigaltstack"); } makecontext(&native_isr_context, native_irq_handler, 0); @@ -510,7 +510,7 @@ void native_interrupt_init(void) _native_in_syscall = 0; if (pipe(_sig_pipefd) == -1) { - err(1, "native_interrupt_init(): pipe()"); + err(EXIT_FAILURE, "native_interrupt_init(): pipe()"); } /* allow for ctrl+c to shut down gracefully */ diff --git a/cpu/native/lpm_cpu.c b/cpu/native/lpm_cpu.c index a690665946..f2737fed01 100644 --- a/cpu/native/lpm_cpu.c +++ b/cpu/native/lpm_cpu.c @@ -66,7 +66,7 @@ void _native_lpm_sleep() } else if (errno != EINTR) { /* select failed for reason other than signal */ - err(1, "lpm_set(): select()"); + err(EXIT_FAILURE, "lpm_set(): select()"); } /* otherwise select was interrupted because of a signal, continue below */ diff --git a/cpu/native/native_cpu.c b/cpu/native/native_cpu.c index 7cd9e47613..4f342cd7e6 100644 --- a/cpu/native/native_cpu.c +++ b/cpu/native/native_cpu.c @@ -88,7 +88,7 @@ char *thread_stack_init(void (*task_func)(void), void *stack_start, int stacksiz #endif if (getcontext(p) == -1) { - err(1, "thread_stack_init(): getcontext()"); + err(EXIT_FAILURE, "thread_stack_init(): getcontext()"); } p->uc_stack.ss_sp = stk; @@ -97,7 +97,7 @@ char *thread_stack_init(void (*task_func)(void), void *stack_start, int stacksiz p->uc_link = &end_context; if (sigemptyset(&(p->uc_sigmask)) == -1) { - err(1, "thread_stack_init(): sigemptyset()"); + err(EXIT_FAILURE, "thread_stack_init(): sigemptyset()"); } makecontext(p, task_func, 0); @@ -123,7 +123,7 @@ void isr_cpu_switch_context_exit(void) _native_in_isr = 0; if (setcontext(ctx) == -1) { - err(1, "cpu_switch_context_exit(): setcontext():"); + err(EXIT_FAILURE, "cpu_switch_context_exit(): setcontext():"); } } @@ -137,7 +137,7 @@ void cpu_switch_context_exit() native_isr_context.uc_stack.ss_flags = 0; makecontext(&native_isr_context, isr_cpu_switch_context_exit, 0); if (setcontext(&native_isr_context) == -1) { - err(1, "cpu_switch_context_exit: swapcontext"); + err(EXIT_FAILURE, "cpu_switch_context_exit: swapcontext"); } } else { @@ -157,7 +157,7 @@ void isr_thread_yield() native_interrupts_enabled = 1; _native_in_isr = 0; if (setcontext(ctx) == -1) { - err(1, "isr_thread_yield(): setcontext()"); + err(EXIT_FAILURE, "isr_thread_yield(): setcontext()"); } } @@ -172,7 +172,7 @@ void thread_yield() native_isr_context.uc_stack.ss_flags = 0; makecontext(&native_isr_context, isr_thread_yield, 0); if (swapcontext(ctx, &native_isr_context) == -1) { - err(1, "thread_yield: swapcontext"); + err(EXIT_FAILURE, "thread_yield: swapcontext"); } eINT(); } @@ -184,7 +184,7 @@ void thread_yield() void native_cpu_init() { if (getcontext(&end_context) == -1) { - err(1, "end_context(): getcontext()"); + err(EXIT_FAILURE, "end_context(): getcontext()"); } end_context.uc_stack.ss_sp = __end_stack; diff --git a/cpu/native/net/tap.c b/cpu/native/net/tap.c index b74b41dc48..b36f831322 100644 --- a/cpu/native/net/tap.c +++ b/cpu/native/net/tap.c @@ -246,12 +246,12 @@ int tap_init(char *name) #ifndef __MACH__ /* tuntap signalled IO not working in OSX */ /* configure fds to send signals on io */ if (fcntl(_native_tap_fd, F_SETOWN, getpid()) == -1) { - err(1, "tap_init(): fcntl(F_SETOWN)"); + err(EXIT_FAILURE, "tap_init(): fcntl(F_SETOWN)"); } /* set file access mode to nonblocking */ if (fcntl(_native_tap_fd, F_SETFL, O_NONBLOCK|O_ASYNC) == -1) { - err(1, "tap_init(): fcntl(F_SETFL)"); + err(EXIT_FAILURE, "tap_init(): fcntl(F_SETFL)"); } #endif /* OSX */ diff --git a/cpu/native/rtc/posix-rtc.c b/cpu/native/rtc/posix-rtc.c index cde2ecf201..748bf991a4 100644 --- a/cpu/native/rtc/posix-rtc.c +++ b/cpu/native/rtc/posix-rtc.c @@ -19,6 +19,7 @@ */ #include +#include #include #include "debug.h" @@ -65,7 +66,7 @@ void rtc_get_localtime(struct tm *localt) t = time(NULL); if (localtime_r(&t, localt) == NULL) { - err(1, "rtc_get_localtime: localtime_r"); + err(EXIT_FAILURE, "rtc_get_localtime: localtime_r"); } _native_syscall_leave(); } @@ -76,7 +77,7 @@ time_t rtc_time(struct timeval *time) if (native_rtc_enabled == 1) { _native_syscall_enter(); if (gettimeofday(time, NULL) == -1) { - err(1, "rtc_time: gettimeofday"); + err(EXIT_FAILURE, "rtc_time: gettimeofday"); } _native_syscall_leave(); }