2011-02-01 Ralf Corsepius <ralf.corsepius@rtems.org>

* libmisc/stringto/stringtounsignedlonglong.c: Reformat range check.
	c99 portability improvements.
This commit is contained in:
Ralf Corsepius
2011-02-01 05:38:01 +00:00
parent 37ecff5c4a
commit c368bd6414
2 changed files with 10 additions and 5 deletions

View File

@@ -1,5 +1,7 @@
2011-02-01 Ralf Corsepius <ralf.corsepius@rtems.org>
* libmisc/stringto/stringtounsignedlonglong.c: Reformat range check.
c99 portability improvements.
* libmisc/stringto/stringtounsignedlong.c: Reformat range check.
* libmisc/stringto/stringtolong.c: Reformat range check.
Add check for result==0.

View File

@@ -21,6 +21,11 @@
#include <rtems/stringto.h>
/* c99 has ULLONG_MAX instead of ULONG_LONG_MAX */
#ifndef ULONG_LONG_MAX
#define ULONG_LONG_MAX ULLONG_MAX
#endif
/*
* Instantiate an error checking wrapper for strtoull (unsigned long long)
*/
@@ -49,11 +54,9 @@ rtems_status_code rtems_string_to_unsigned_long_long (
if ( end == s )
return RTEMS_NOT_DEFINED;
if ( (result == ULONG_LONG_MAX) && (errno == ERANGE) )
return RTEMS_INVALID_NUMBER;
if ( (result == 0) && (errno == ERANGE) )
return RTEMS_INVALID_NUMBER;
if ( ( errno == ERANGE ) &&
(( result == 0 ) || ( result == ULONG_LONG_MAX )))
return RTEMS_INVALID_NUMBER;
*n = result;