parent
7920b57d34
commit
3789a75ed6
|
@ -276,10 +276,10 @@ namespace Genode {
|
||||||
* characters in front of the number. If the number is prefixed with "0x",
|
* characters in front of the number. If the number is prefixed with "0x",
|
||||||
* a base of 16 is used, otherwise a base of 10.
|
* a base of 16 is used, otherwise a base of 10.
|
||||||
*/
|
*/
|
||||||
inline size_t ascii_to_unsigned_long(const char *s, unsigned long &result,
|
template <typename T>
|
||||||
unsigned base)
|
inline size_t ascii_to_unsigned(const char *s, T &result, unsigned base)
|
||||||
{
|
{
|
||||||
unsigned long i = 0, value = 0;
|
T i = 0, value = 0;
|
||||||
|
|
||||||
if (!*s) return i;
|
if (!*s) return i;
|
||||||
|
|
||||||
|
@ -334,10 +334,22 @@ namespace Genode {
|
||||||
*/
|
*/
|
||||||
inline size_t ascii_to(const char *s, unsigned long &result)
|
inline size_t ascii_to(const char *s, unsigned long &result)
|
||||||
{
|
{
|
||||||
return ascii_to_unsigned_long(s, result, 0);
|
return ascii_to_unsigned(s, result, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read unsigned long long value from string
|
||||||
|
*
|
||||||
|
* \return number of consumed characters
|
||||||
|
*/
|
||||||
|
inline size_t ascii_to(const char *s, unsigned long long &result)
|
||||||
|
{
|
||||||
|
return ascii_to_unsigned(s, result, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read unsigned int value from string
|
* Read unsigned int value from string
|
||||||
*
|
*
|
||||||
|
@ -345,10 +357,7 @@ namespace Genode {
|
||||||
*/
|
*/
|
||||||
inline size_t ascii_to(const char *s, unsigned int &result)
|
inline size_t ascii_to(const char *s, unsigned int &result)
|
||||||
{
|
{
|
||||||
unsigned long result_long = 0;
|
return ascii_to_unsigned(s, result, 0);
|
||||||
size_t ret = ascii_to_unsigned_long(s, result_long, 0);
|
|
||||||
result = result_long;
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -369,7 +378,7 @@ namespace Genode {
|
||||||
int j = 0;
|
int j = 0;
|
||||||
unsigned long value = 0;
|
unsigned long value = 0;
|
||||||
|
|
||||||
j = ascii_to_unsigned_long(s, value, 10);
|
j = ascii_to_unsigned(s, value, 10);
|
||||||
|
|
||||||
if (!j) return i;
|
if (!j) return i;
|
||||||
|
|
||||||
|
@ -391,7 +400,7 @@ namespace Genode {
|
||||||
unsigned long res = 0;
|
unsigned long res = 0;
|
||||||
|
|
||||||
/* convert numeric part of string */
|
/* convert numeric part of string */
|
||||||
int i = ascii_to_unsigned_long(s, res, 0);
|
int i = ascii_to_unsigned(s, res, 0);
|
||||||
|
|
||||||
/* handle suffixes */
|
/* handle suffixes */
|
||||||
if (i > 0)
|
if (i > 0)
|
||||||
|
|
|
@ -1034,7 +1034,7 @@ int dev_set_name(struct device *dev, const char *fmt, ...)
|
||||||
int strict_strtoul(const char *s, unsigned int base, unsigned long *res)
|
int strict_strtoul(const char *s, unsigned int base, unsigned long *res)
|
||||||
{
|
{
|
||||||
unsigned long r = -EINVAL;
|
unsigned long r = -EINVAL;
|
||||||
Genode::ascii_to_unsigned_long(s, r, base);
|
Genode::ascii_to_unsigned(s, r, base);
|
||||||
*res = r;
|
*res = r;
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
|
|
|
@ -69,7 +69,7 @@ class Vfs::Tar_file_system : public File_system
|
||||||
strncpy(buf, field, sizeof(buf));
|
strncpy(buf, field, sizeof(buf));
|
||||||
|
|
||||||
unsigned long value = 0;
|
unsigned long value = 0;
|
||||||
Genode::ascii_to_unsigned_long(buf, value, 8);
|
Genode::ascii_to_unsigned(buf, value, 8);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ namespace File_system {
|
||||||
strncpy(buf, field, sizeof(buf));
|
strncpy(buf, field, sizeof(buf));
|
||||||
|
|
||||||
unsigned long value = 0;
|
unsigned long value = 0;
|
||||||
ascii_to_unsigned_long(buf, value, 8);
|
ascii_to_unsigned(buf, value, 8);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -79,8 +79,8 @@ class Rom_session_component : public Genode::Rpc_object<Genode::Rom_session>
|
||||||
while (block_id < block_cnt) {
|
while (block_id < block_cnt) {
|
||||||
|
|
||||||
unsigned long file_size = 0;
|
unsigned long file_size = 0;
|
||||||
Genode::ascii_to_unsigned_long(_tar_addr + block_id*_BLOCK_LEN + _FIELD_SIZE_LEN,
|
Genode::ascii_to_unsigned(_tar_addr + block_id*_BLOCK_LEN +
|
||||||
file_size, 8);
|
_FIELD_SIZE_LEN, file_size, 8);
|
||||||
|
|
||||||
/* get name of tar record */
|
/* get name of tar record */
|
||||||
char const *record_filename = _tar_addr + block_id*_BLOCK_LEN;
|
char const *record_filename = _tar_addr + block_id*_BLOCK_LEN;
|
||||||
|
|
Loading…
Reference in New Issue