From 829b94dc988861179f09f56b6693c84fda02acd1 Mon Sep 17 00:00:00 2001 From: Kapil Porwal Date: Wed, 5 Jun 2024 15:52:30 +0000 Subject: 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 Reviewed-on: https://review.coreboot.org/c/coreboot/+/82910 Reviewed-by: Jakub Czapiga Tested-by: build bot (Jenkins) Reviewed-by: Subrata Banik --- src/commonlib/bsd/string.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/commonlib/bsd/string.c (limited to 'src/commonlib/bsd/string.c') diff --git a/src/commonlib/bsd/string.c b/src/commonlib/bsd/string.c new file mode 100644 index 0000000000..3286d41b1c --- /dev/null +++ b/src/commonlib/bsd/string.c @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: BSD-3-Clause */ + +#include +#include + +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; +} -- cgit v1.2.3