[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[XTF PATCH v1 05/15] common: add simple atou()


  • To: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: dmukhin@xxxxxxxx
  • Date: Wed, 4 Nov 2026 17:38:07 -0800
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 148.163.138.245) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=ford.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=ford.com; dkim=pass (signature was verified) header.d=saarlouis.ford.com; dkim=pass (signature was verified) header.d=ford.com; arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=7ZN6LuhG///1TOpgWfiNFXmahkcaCTnzZxgTiky8Tpc=; b=i7DgbTJZF0zyS29mfyeBwikXy6qW0jQEim8ak++ulaO1s+KOYQIf2OuuxH6WxBDk0IYcPh4H+hCq4dHSIGMHNzb1nb8SylrXKVeTs8iT0728dapzzUDayo2tfm1Ai0vPtBbyTkqI321jijPW6l1Q886BOcf4gM5uqwrz7C2D91IwZQ8DWyN3KfIaAsINEpmRm+oSO6z4ODY7L8MLJnUuFqhFUAUtF2uU6Da1QwrO1Bqq4qnNJf/z2Jz3CKDvrNihe9lVZO5tvUf7TlMUSMKBe3GEN+12CH4IQCxA4OmjyqIv7e3EYJ+kVIp3U5bf7+8OE2eG3NZ6a/mpANI8v8E3Tg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=OnBAlriM0pXbMAnPkYYrWizUZFGo2+jglSd3TDm7cblU+hlJ3tZjxmjuimIxYnn5OYWlZWJGdatffRUd5FskLFkL5Hq8r72m0Y77oO4pnj2hOICpM51EnK8VCYKsHOXQg9cNyiV+upAsPOGWI5H1VE+erlvVU2HzC+XTLILqE0vn/wRo2LeJBi95cmf/BFMHPXR64HO5sFVYh+CqoWSNgF881EkcS7b/JXMwn7MLI6l6kQfByqcXVNVrEzJ1x+hXkNrtyZenZ/gAVKsQ1AgcEgR6EPiuTL7qtNs2tzIW4MrvfE33DCi7m/ny2N/gSwZz8ygE2cmNMb7unEPewSmWdA==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=ppford header.d=ford.com header.i="@ford.com" header.h="Cc:Content-Transfer-Encoding:Content-Type:Date:From:In-Reply-To:Message-ID:MIME-Version:References:Subject:To"; dkim=pass header.s=selector2-azureford-onmicrosoft-com header.d=azureford.onmicrosoft.com header.i="@azureford.onmicrosoft.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"; dkim=pass header.s=ppserprodsaar header.d=saarlouis.ford.com header.i="@saarlouis.ford.com" header.h="Cc:Content-Transfer-Encoding:Date:From:In-Reply-To:Message-ID:MIME-Version:References:Subject:To"; dkim=pass header.s=ppfserpocford header.d=ford.com header.i="@ford.com" header.h="Cc:Content-Transfer-Encoding:Date:From:In-Reply-To:Message-ID:MIME-Version:References:Subject:To"
  • Cc: andrew.cooper3@xxxxxxxxxx, anthony.perard@xxxxxxxxxx, jbeulich@xxxxxxxx, julien@xxxxxxx, michal.orzel@xxxxxxx, roger@xxxxxxxxxxxxxx, sstabellini@xxxxxxxxxx, dmukhin@xxxxxxx, Denis Mukhin <dmukhin@xxxxxxxx>
  • Delivery-date: Thu, 05 Nov 2026 01:38:49 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Pser-m365-app: SER-APP

From: Denis Mukhin <dmukhin@xxxxxxxx>

Signed-off-by: Denis Mukhin <dmukhin@xxxxxxxx>
---
 common/libc/string.c | 24 ++++++++++++++++++++++++
 include/xtf/libc.h   |  2 ++
 2 files changed, 26 insertions(+)

diff --git a/common/libc/string.c b/common/libc/string.c
index 8ddceab7419d..e0e40ccfa1df 100644
--- a/common/libc/string.c
+++ b/common/libc/string.c
@@ -97,6 +97,30 @@ int (memcmp)(const void *s1, const void *s2, size_t n)
     return res;
 }
 
+unsigned int atou(const char *s)
+{
+    unsigned int val = 0;
+
+    while ( *s == ' ' || *s == '\t' || *s == '\n' ||
+            *s == '\r' || *s == '\f' || *s == '\v' )
+        ++s;
+
+    if ( *s == '+' )
+        ++s;
+
+    while ( *s >= '0' && *s <= '9' )
+    {
+        unsigned int digit = *s++ - '0';
+
+        if ( val > (~0u - digit) / 10 )
+            return ~0u;
+
+        val = val * 10 + digit;
+    }
+
+    return val;
+}
+
 /*
  * Local variables:
  * mode: C
diff --git a/include/xtf/libc.h b/include/xtf/libc.h
index 86d2abdf2c6a..62fd37c77d65 100644
--- a/include/xtf/libc.h
+++ b/include/xtf/libc.h
@@ -40,6 +40,8 @@ int memcmp(const void *s1, const void *s2, size_t n);
 
 size_t strnlen(const char *str, size_t max);
 
+unsigned int atou(const char *s);
+
 /*
  * Internal version of vsnprintf(), taking extra control flags.
  *
-- 
2.55.0




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.