summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2013-12-11 14:54:22 -0600
committerGregory Nutt <gnutt@nuttx.org>2013-12-11 14:54:22 -0600
commite376719b727dea88c81ad2111769ab8a596c6f84 (patch)
tree9ba2b5ae6f6e6bbca0c2627d9cb753267544eaf8
parent159d94fddf49ad8e361714d9e8f6187586651be4 (diff)
downloadnuttx-e376719b727dea88c81ad2111769ab8a596c6f84.tar.gz
nuttx-e376719b727dea88c81ad2111769ab8a596c6f84.tar.bz2
nuttx-e376719b727dea88c81ad2111769ab8a596c6f84.zip
libc logic should not directly assign errno, but should use set_errno() macro. This is because in the kernel build, errno is a system call
-rw-r--r--nuttx/libc/math/lib_sqrt.c2
-rw-r--r--nuttx/libc/math/lib_sqrtf.c2
-rw-r--r--nuttx/libc/math/lib_sqrtl.c2
-rw-r--r--nuttx/libc/stdio/lib_sscanf.c8
4 files changed, 7 insertions, 7 deletions
diff --git a/nuttx/libc/math/lib_sqrt.c b/nuttx/libc/math/lib_sqrt.c
index e8a1c42ea..dbab598bc 100644
--- a/nuttx/libc/math/lib_sqrt.c
+++ b/nuttx/libc/math/lib_sqrt.c
@@ -48,7 +48,7 @@ double sqrt(double x)
if (x < 0.0)
{
- errno = EDOM;
+ set_errno(EDOM);
return NAN;
}
diff --git a/nuttx/libc/math/lib_sqrtf.c b/nuttx/libc/math/lib_sqrtf.c
index cf45ccacc..e70a1de72 100644
--- a/nuttx/libc/math/lib_sqrtf.c
+++ b/nuttx/libc/math/lib_sqrtf.c
@@ -49,7 +49,7 @@ float sqrtf(float x)
if (x < 0.0)
{
- errno = EDOM;
+ set_errno(EDOM);
return NAN;
}
diff --git a/nuttx/libc/math/lib_sqrtl.c b/nuttx/libc/math/lib_sqrtl.c
index 4035992fe..181adf0c8 100644
--- a/nuttx/libc/math/lib_sqrtl.c
+++ b/nuttx/libc/math/lib_sqrtl.c
@@ -50,7 +50,7 @@ long double sqrtl(long double x)
if (x < 0.0)
{
- errno = EDOM;
+ set_errno(EDOM);
return NAN;
}
diff --git a/nuttx/libc/stdio/lib_sscanf.c b/nuttx/libc/stdio/lib_sscanf.c
index b4c7ef9fe..00d4b71f6 100644
--- a/nuttx/libc/stdio/lib_sscanf.c
+++ b/nuttx/libc/stdio/lib_sscanf.c
@@ -446,7 +446,7 @@ int vsscanf(FAR const char *buf, FAR const char *fmt, va_list ap)
long tmplong;
errsave = errno;
- errno = 0;
+ set_errno(0);
tmplong = strtol(tmp, &endptr, base);
/* Number can't be converted */
@@ -456,7 +456,7 @@ int vsscanf(FAR const char *buf, FAR const char *fmt, va_list ap)
return count;
}
- errno = errsave;
+ set_errno(errno);
/* We have to check whether we need to return a long
* or an int.
@@ -556,7 +556,7 @@ int vsscanf(FAR const char *buf, FAR const char *fmt, va_list ap)
double_t dvalue;
errsave = errno;
- errno = 0;
+ set_errno(0);
dvalue = strtod(tmp, &endptr);
/* Number can't be converted */
@@ -566,7 +566,7 @@ int vsscanf(FAR const char *buf, FAR const char *fmt, va_list ap)
return count;
}
- errno = errsave;
+ set_errno(errsave);
/* We have to check whether we need to return a float
* or a double.