summaryrefslogtreecommitdiffstats
path: root/cpukit/libmisc
diff options
context:
space:
mode:
authorRalf Corsepius <ralf.corsepius@rtems.org>2011-02-01 05:39:20 +0000
committerRalf Corsepius <ralf.corsepius@rtems.org>2011-02-01 05:39:20 +0000
commit5df16fab538ae5bb77bd25b13692ae7597825c79 (patch)
tree1b26f3344e171b64ddd2b3301831500bfc82c73b /cpukit/libmisc
parent2011-02-01 Ralf Corsepius <ralf.corsepius@rtems.org> (diff)
downloadrtems-5df16fab538ae5bb77bd25b13692ae7597825c79.tar.bz2
2011-02-01 Ralf Corsepius <ralf.corsepius@rtems.org>
* libmisc/stringto/stringtolonglong.c: Reformat range check. c99 portability improvements. Add check for result==0.
Diffstat (limited to 'cpukit/libmisc')
-rw-r--r--cpukit/libmisc/stringto/stringtolonglong.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/cpukit/libmisc/stringto/stringtolonglong.c b/cpukit/libmisc/stringto/stringtolonglong.c
index 206437b658..d291262477 100644
--- a/cpukit/libmisc/stringto/stringtolonglong.c
+++ b/cpukit/libmisc/stringto/stringtolonglong.c
@@ -21,6 +21,15 @@
#include <rtems/stringto.h>
+/* c99 has LLONG_MAX instead of LONG_LONG_MAX */
+#ifndef LONG_LONG_MAX
+#define LONG_LONG_MAX LLONG_MAX
+#endif
+/* c99 has LLONG_MIN instead of LONG_LONG_MIN */
+#ifndef LONG_LONG_MIN
+#define LONG_LONG_MIN LLONG_MIN
+#endif
+
/*
* Instantiate an error checking wrapper for strtoll (long long)
*/
@@ -49,11 +58,9 @@ rtems_status_code rtems_string_to_long_long (
if ( end == s )
return RTEMS_NOT_DEFINED;
- if ( (result == LONG_LONG_MAX) && (errno == ERANGE) )
- return RTEMS_INVALID_NUMBER;
-
- if ( (result == LONG_LONG_MIN) && (errno == ERANGE) )
- return RTEMS_INVALID_NUMBER;
+ if ( ( errno == ERANGE ) &&
+ (( result == 0 ) || ( result == LONG_LONG_MAX ) || ( result == LONG_LONG_MIN )))
+ return RTEMS_INVALID_NUMBER;
*n = result;