treewide: Move skip_atoi function to commonlib
BUG=none TEST=Build and verify on Screebo TEST=make unit-tests ``` $ make tests/commonlib/bsd/string-test [==========] tests_commonlib_bsd_string-test(tests): Running 1 test(s). [ RUN ] test_skip_atoi [ OK ] test_skip_atoi [==========] tests_commonlib_bsd_string-test(tests): 1 test(s) run. [ PASSED ] 1 test(s). ``` Change-Id: Ifaaa80d0c696a625592ce301f9e3eefb2b4dcd98 Signed-off-by: Maximilian Brune <maximilian.brune@9elements.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/82910 Reviewed-by: Jakub Czapiga <czapiga@google.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Subrata Banik <subratabanik@google.com>
This commit is contained in:
parent
3da7829958
commit
829b94dc98
10 changed files with 74 additions and 42 deletions
15
src/commonlib/bsd/string.c
Normal file
15
src/commonlib/bsd/string.c
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
/* SPDX-License-Identifier: BSD-3-Clause */
|
||||
|
||||
#include <commonlib/bsd/string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
unsigned int skip_atoi(char **ptr)
|
||||
{
|
||||
unsigned int result = 0;
|
||||
char *str;
|
||||
|
||||
for (str = *ptr; isdigit(str[0]); str++)
|
||||
result = result * 10 + (str[0] - '0');
|
||||
*ptr = str;
|
||||
return result;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue