diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2009-12-01 22:16:10 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2009-12-01 22:16:10 +0000 |
commit | 2c6a3e7e2eadef996b918992d36e9855e8dc5e9e (patch) | |
tree | e2a471a252c09faa5d2a3bb6e8141bdc7fbca758 /cpukit | |
parent | 2009-12-01 Joel Sherrill <joel.sherrill@OARcorp.com> (diff) | |
download | rtems-2c6a3e7e2eadef996b918992d36e9855e8dc5e9e.tar.bz2 |
2009-12-01 Joel Sherrill <joel.sherrill@OARcorp.com>
* libmisc/stringto/stringto.h, libmisc/stringto/stringto_template.h:
Tidy up as part of adding new test.
Diffstat (limited to 'cpukit')
-rw-r--r-- | cpukit/ChangeLog | 5 | ||||
-rw-r--r-- | cpukit/libmisc/stringto/stringto.h | 21 | ||||
-rw-r--r-- | cpukit/libmisc/stringto/stringto_template.h | 7 |
3 files changed, 33 insertions, 0 deletions
diff --git a/cpukit/ChangeLog b/cpukit/ChangeLog index fb07014b5a..e41e44c21c 100644 --- a/cpukit/ChangeLog +++ b/cpukit/ChangeLog @@ -1,3 +1,8 @@ +2009-12-01 Joel Sherrill <joel.sherrill@OARcorp.com> + + * libmisc/stringto/stringto.h, libmisc/stringto/stringto_template.h: + Tidy up as part of adding new test. + 2009-12-01 Joel Sherrill <joel.sherrill@oarcorp.com> * libcsupport/Makefile.am: Split no_posix.c so using sleep() does not diff --git a/cpukit/libmisc/stringto/stringto.h b/cpukit/libmisc/stringto/stringto.h index e0ba24416c..af2fd2f083 100644 --- a/cpukit/libmisc/stringto/stringto.h +++ b/cpukit/libmisc/stringto/stringto.h @@ -78,6 +78,27 @@ rtems_status_code rtems_string_to_int( ); /** + * @brief Convert String to Unsigned Int (with validation) + * + * This method converts a string to an unsigned int with range validation. + * + * @param[in] s is the string to convert + * @param[in] n points to the variable to place the converted output in + * @param[in] endptr is used to keep track of the position in the string + * @param[in] base is the expected base of the number + * + * @return This method returns RTEMS_SUCCESSFUL on successful conversion + * and *n is filled in. Otherwise, the status indicates the + * source of the error. + */ +rtems_status_code rtems_string_to_unsigned_int( + const char *s, + unsigned int *n, + char **endptr, + int base +); + +/** * @brief Convert String to Long (with validation) * * This method converts a string to a long with diff --git a/cpukit/libmisc/stringto/stringto_template.h b/cpukit/libmisc/stringto/stringto_template.h index a1503e0d87..4972d5fbac 100644 --- a/cpukit/libmisc/stringto/stringto_template.h +++ b/cpukit/libmisc/stringto/stringto_template.h @@ -104,9 +104,16 @@ rtems_status_code STRING_TO_NAME ( if ( end == s ) return RTEMS_NOT_DEFINED; + /* + * In theory, we should check this but newlib never returns anything + * but range errors. So this is unreachable code based upon the newlib + * implementation of strXXX methods as of 1 December 2009. --joel + */ + #if 0 /* there was a conversion error */ if ( (result == ZERO) && errno ) return RTEMS_INVALID_NUMBER; + #endif #ifdef STRING_TO_MAX /* there was an overflow */ |