mirror of
https://github.com/ipxe/ipxe
synced 2025-12-24 06:22:59 +03:00
[libc] Rewrite strtoul()
The implementation of strtoul() has a partially unknown provenance. Rewrite this code to avoid potential licensing uncertainty. Since we now use -ffunction-sections, there is no need to place strtoull() in a separate file from strtoul(). Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
@@ -20,9 +20,10 @@
|
||||
FILE_LICENCE ( GPL2_OR_LATER );
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
#include <ipxe/string.h>
|
||||
#include <ipxe/base16.h>
|
||||
|
||||
/** @file
|
||||
@@ -87,13 +88,13 @@ int hex_decode ( const char *encoded, char separator, void *data, size_t len ) {
|
||||
|
||||
/* Extract digits. Note that either digit may be NUL,
|
||||
* which would be interpreted as an invalid value by
|
||||
* strtoul_charval(); there is therefore no need for an
|
||||
* digit_value(); there is therefore no need for an
|
||||
* explicit end-of-string check.
|
||||
*/
|
||||
sixteens = strtoul_charval ( *(encoded++) );
|
||||
sixteens = digit_value ( *(encoded++) );
|
||||
if ( sixteens >= 16 )
|
||||
return -EINVAL;
|
||||
units = strtoul_charval ( *(encoded++) );
|
||||
units = digit_value ( *(encoded++) );
|
||||
if ( units >= 16 )
|
||||
return -EINVAL;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user