[PATCH] lib: fwts_ioport: use sigsetjmp and siglongjmp
Keng-Yu Lin
keng-yu.lin at canonical.com
Tue Sep 23 04:35:13 UTC 2014
On Sat, Sep 20, 2014 at 2:22 AM, Colin King <colin.king at canonical.com> wrote:
> From: Colin Ian King <colin.king at canonical.com>
>
> Saving the process's current signal mask is desirable, so use
> sigsetjmp and siglongjmp.
>
> Signed-off-by: Colin Ian King <colin.king at canonical.com>
> ---
> src/lib/src/fwts_ioport.c | 16 ++++++++--------
> 1 file changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/src/lib/src/fwts_ioport.c b/src/lib/src/fwts_ioport.c
> index 348ccd1..e433995 100644
> --- a/src/lib/src/fwts_ioport.c
> +++ b/src/lib/src/fwts_ioport.c
> @@ -26,7 +26,7 @@
> #include <signal.h>
> #include <setjmp.h>
>
> -static jmp_buf jmpbuf;
> +static sigjmp_buf jmpbuf;
>
> /*
> * If we hit a SIGSEGV then the port read
> @@ -38,7 +38,7 @@ static void segv_handler(int dummy)
> FWTS_UNUSED(dummy);
>
> signal(SIGSEGV, SIG_DFL);
> - longjmp(jmpbuf, 1);
> + siglongjmp(jmpbuf, 1);
> }
>
> /*
> @@ -47,7 +47,7 @@ static void segv_handler(int dummy)
> */
> int fwts_inb(uint32_t port, uint8_t *value)
> {
> - if (setjmp(jmpbuf) != 0)
> + if (sigsetjmp(jmpbuf, 1) != 0)
> return FWTS_ERROR;
>
> signal(SIGSEGV, segv_handler);
> @@ -63,7 +63,7 @@ int fwts_inb(uint32_t port, uint8_t *value)
> */
> int fwts_inw(uint32_t port, uint16_t *value)
> {
> - if (setjmp(jmpbuf) != 0)
> + if (sigsetjmp(jmpbuf, 1) != 0)
> return FWTS_ERROR;
>
> signal(SIGSEGV, segv_handler);
> @@ -79,7 +79,7 @@ int fwts_inw(uint32_t port, uint16_t *value)
> */
> int fwts_inl(uint32_t port, uint32_t *value)
> {
> - if (setjmp(jmpbuf) != 0)
> + if (sigsetjmp(jmpbuf, 1) != 0)
> return FWTS_ERROR;
>
> signal(SIGSEGV, segv_handler);
> @@ -95,7 +95,7 @@ int fwts_inl(uint32_t port, uint32_t *value)
> */
> int fwts_outb(uint32_t port, uint8_t value)
> {
> - if (setjmp(jmpbuf) != 0)
> + if (sigsetjmp(jmpbuf, 1) != 0)
> return FWTS_ERROR;
>
> signal(SIGSEGV, segv_handler);
> @@ -111,7 +111,7 @@ int fwts_outb(uint32_t port, uint8_t value)
> */
> int fwts_outw(uint32_t port, uint16_t value)
> {
> - if (setjmp(jmpbuf) != 0)
> + if (sigsetjmp(jmpbuf, 1) != 0)
> return FWTS_ERROR;
>
> signal(SIGSEGV, segv_handler);
> @@ -127,7 +127,7 @@ int fwts_outw(uint32_t port, uint16_t value)
> */
> int fwts_outl(uint32_t port, uint32_t value)
> {
> - if (setjmp(jmpbuf) != 0)
> + if (sigsetjmp(jmpbuf, 1) != 0)
> return FWTS_ERROR;
>
> signal(SIGSEGV, segv_handler);
> --
> 2.1.0
>
>
Acked-by: Keng-Yu Lin <kengyu at canonical.com>
More information about the fwts-devel
mailing list