summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2015-04-09 08:05:47 -0600
committerGregory Nutt <gnutt@nuttx.org>2015-04-09 08:05:47 -0600
commitda035c45b45d655eb20b21d5739398482997a37d (patch)
tree2ed9095671b7700e5df07c5ed2abf5a47184ed22
parente7c87b81000e3a77df7d7d7f1e14f7b3309ca1d0 (diff)
downloadpx4-nuttx-da035c45b45d655eb20b21d5739398482997a37d.tar.gz
px4-nuttx-da035c45b45d655eb20b21d5739398482997a37d.tar.bz2
px4-nuttx-da035c45b45d655eb20b21d5739398482997a37d.zip
sigaddset() and sigdelset() need to set errno if a bad signal number is received
-rw-r--r--nuttx/libc/signal/sig_addset.c35
-rw-r--r--nuttx/libc/signal/sig_delset.c36
-rw-r--r--nuttx/libc/signal/sig_emptyset.c23
3 files changed, 19 insertions, 75 deletions
diff --git a/nuttx/libc/signal/sig_addset.c b/nuttx/libc/signal/sig_addset.c
index 3a9da104c..1379d3ceb 100644
--- a/nuttx/libc/signal/sig_addset.c
+++ b/nuttx/libc/signal/sig_addset.c
@@ -38,26 +38,7 @@
****************************************************************************/
#include <signal.h>
-
-/****************************************************************************
- * Pre-processor Definitions
- ****************************************************************************/
-
-/****************************************************************************
- * Private Type Declarations
- ****************************************************************************/
-
-/****************************************************************************
- * Global Variables
- ****************************************************************************/
-
-/****************************************************************************
- * Private Variables
- ****************************************************************************/
-
-/****************************************************************************
- * Private Function Prototypes
- ****************************************************************************/
+#include <errno.h>
/****************************************************************************
* Public Functions
@@ -83,18 +64,18 @@
int sigaddset(FAR sigset_t *set, int signo)
{
- int ret = ERROR;
-
/* Verify the signal */
- if (GOOD_SIGNO(signo))
+ if (!GOOD_SIGNO(signo))
+ {
+ set_errno(EINVAL);
+ return ERROR;
+ }
+ else
{
/* Add the signal to the set */
*set |= SIGNO2SET(signo);
- ret = OK;
+ return OK;
}
-
- return ret;
}
-
diff --git a/nuttx/libc/signal/sig_delset.c b/nuttx/libc/signal/sig_delset.c
index 58e17ec1e..9c488e701 100644
--- a/nuttx/libc/signal/sig_delset.c
+++ b/nuttx/libc/signal/sig_delset.c
@@ -38,26 +38,7 @@
****************************************************************************/
#include <signal.h>
-
-/****************************************************************************
- * Pre-processor Definitions
- ****************************************************************************/
-
-/****************************************************************************
- * Private Type Declarations
- ****************************************************************************/
-
-/****************************************************************************
- * Global Variables
- ****************************************************************************/
-
-/****************************************************************************
- * Private Variables
- ****************************************************************************/
-
-/****************************************************************************
- * Private Function Prototypes
- ****************************************************************************/
+#include <errno.h>
/****************************************************************************
* Public Functions
@@ -83,18 +64,19 @@
int sigdelset(FAR sigset_t *set, int signo)
{
- int ret = ERROR;
-
/* Verify the signal */
- if (GOOD_SIGNO(signo))
+ if (!GOOD_SIGNO(signo))
+ {
+ set_errno(EINVAL);
+ return ERROR;
+ }
+ else
{
- /* Delete the signal to the set */
+ /* Remove the signal from the set */
*set &= ~SIGNO2SET(signo);
- ret = OK;
+ return OK;
}
-
- return ret;
}
diff --git a/nuttx/libc/signal/sig_emptyset.c b/nuttx/libc/signal/sig_emptyset.c
index 4163fe156..c41ae65a4 100644
--- a/nuttx/libc/signal/sig_emptyset.c
+++ b/nuttx/libc/signal/sig_emptyset.c
@@ -38,26 +38,7 @@
****************************************************************************/
#include <signal.h>
-
-/****************************************************************************
- * Pre-processor Definitions
- ****************************************************************************/
-
-/****************************************************************************
- * Private Type Declarations
- ****************************************************************************/
-
-/****************************************************************************
- * Global Variables
- ****************************************************************************/
-
-/****************************************************************************
- * Private Variables
- ****************************************************************************/
-
-/****************************************************************************
- * Private Functions
- ****************************************************************************/
+#include <errno.h>
/****************************************************************************
* Public Functions
@@ -71,7 +52,7 @@
* signals are excluded.
*
* Parameters:
- * set - Signal set to initalize
+ * set - Signal set to initialize
*
* Return Value:
* 0 (OK), or -1 (ERROR) if the signal set cannot be initialized.