sigaddset() and sigdelset() need to set errno if a bad signal number is received

This commit is contained in:
Gregory Nutt 2015-04-09 08:05:47 -06:00
parent 2c53894065
commit f6b05529da
3 changed files with 19 additions and 75 deletions

@ -38,26 +38,7 @@
****************************************************************************/ ****************************************************************************/
#include <signal.h> #include <signal.h>
#include <errno.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Type Declarations
****************************************************************************/
/****************************************************************************
* Global Variables
****************************************************************************/
/****************************************************************************
* Private Variables
****************************************************************************/
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
@ -83,18 +64,18 @@
int sigaddset(FAR sigset_t *set, int signo) int sigaddset(FAR sigset_t *set, int signo)
{ {
int ret = ERROR;
/* Verify the signal */ /* Verify the signal */
if (GOOD_SIGNO(signo)) if (!GOOD_SIGNO(signo))
{
set_errno(EINVAL);
return ERROR;
}
else
{ {
/* Add the signal to the set */ /* Add the signal to the set */
*set |= SIGNO2SET(signo); *set |= SIGNO2SET(signo);
ret = OK; return OK;
} }
return ret;
} }

@ -38,26 +38,7 @@
****************************************************************************/ ****************************************************************************/
#include <signal.h> #include <signal.h>
#include <errno.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Type Declarations
****************************************************************************/
/****************************************************************************
* Global Variables
****************************************************************************/
/****************************************************************************
* Private Variables
****************************************************************************/
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
@ -83,18 +64,19 @@
int sigdelset(FAR sigset_t *set, int signo) int sigdelset(FAR sigset_t *set, int signo)
{ {
int ret = ERROR;
/* Verify the signal */ /* Verify the signal */
if (GOOD_SIGNO(signo)) if (!GOOD_SIGNO(signo))
{ {
/* Delete the signal to the set */ set_errno(EINVAL);
return ERROR;
}
else
{
/* Remove the signal from the set */
*set &= ~SIGNO2SET(signo); *set &= ~SIGNO2SET(signo);
ret = OK; return OK;
} }
return ret;
} }

@ -38,26 +38,7 @@
****************************************************************************/ ****************************************************************************/
#include <signal.h> #include <signal.h>
#include <errno.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Type Declarations
****************************************************************************/
/****************************************************************************
* Global Variables
****************************************************************************/
/****************************************************************************
* Private Variables
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
@ -71,7 +52,7 @@
* signals are excluded. * signals are excluded.
* *
* Parameters: * Parameters:
* set - Signal set to initalize * set - Signal set to initialize
* *
* Return Value: * Return Value:
* 0 (OK), or -1 (ERROR) if the signal set cannot be initialized. * 0 (OK), or -1 (ERROR) if the signal set cannot be initialized.