From 2032d33ca494d087ca7609cd18dee829173f85f6 Mon Sep 17 00:00:00 2001
From: Leah Rowe <leah@libreboot.org>
Date: Tue, 6 Jun 2023 00:52:10 +0100
Subject: [PATCH 1/2] string: properly cast c value in memset()

Per C standard, whether char is signed or unsigned
is *implementation-defined*, but IEEE Std 1003.1-2017
states:

memset() shall copy c (converted to unsigned char) to
each of the first n bytes of the object pointed to by
s; if converting c to unsigned char, it also makes sense
to cast s to unsigned char * (where the current code
casts it to ambiguous char *)

Signed-off-by: Leah Rowe <leah@libreboot.org>
---
 src/string.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/string.c b/src/string.c
index adb8198..b45565a 100644
--- a/src/string.c
+++ b/src/string.c
@@ -110,7 +110,7 @@ void *
 memset(void *s, int c, size_t n)
 {
     while (n)
-        ((char *)s)[--n] = c;
+        ((unsigned char *)s)[--n] = (unsigned char) c;
     return s;
 }
 
-- 
2.40.1

