From b6f3c00fbdec538154d4424da4ed117366ccae7e Mon Sep 17 00:00:00 2001 From: Thomas Heijligen Date: Mon, 8 Aug 2022 22:19:33 +0200 Subject: layout.c: Cast argument of isspace() to unsigned char These functions [isspace, etc] check whether c [(the argument)], which must have the value of an unsigned char or EOF, falls into a certain character class according to the current locale. Cast the argument from `char` to `unsigned char` to guarantee that we don't pass illegal negative values. Some implementations actually provide a warning to get heads up[1]. [1] https://man.netbsd.org/ctype.3#CAVEATS TEST=Builds on Cygwin (Windows 10, amd64, gcc 11.3.0) Change-Id: Ia48d5a19b0964bc28e5360edf06bdf287dad5945 Signed-off-by: Thomas Heijligen Reviewed-on: https://review.coreboot.org/c/flashrom/+/66548 Reviewed-by: Nico Huber Tested-by: build bot (Jenkins) Reviewed-by: Angel Pons Reviewed-by: Anastasia Klimchuk --- layout.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'layout.c') diff --git a/layout.c b/layout.c index 39f504acf..5916d66f5 100644 --- a/layout.c +++ b/layout.c @@ -312,7 +312,7 @@ void prepare_layout_for_extraction(struct flashctx *flash) entry->file = strdup(entry->name); for (i = 0; entry->file[i]; ++i) { - if (isspace(entry->file[i])) + if (isspace((unsigned char)entry->file[i])) entry->file[i] = '_'; } } -- cgit v1.2.3