From d5f6b68df16f57f2a5bdc87c903d239454d6c3e8 Mon Sep 17 00:00:00 2001 From: Robin Jarry Date: Sun, 7 May 2023 00:37:28 +0200 Subject: filters: fix option parsing on arm cpus When running colorize or wrap on ARM, both programs exit immediately displaying their help message whatever the provided arguments. This is caused by an implicit downcast of the getopt return value. On most architectures, char is signed by default. On ARM, char is unsigned for performance reasons. Since the signed int return value of getopt is forced into a char, the results differ on ARM compared to x86. * Add -Wconversion -Warith-conversion to CFLAGS in CI builds to ensure catching such issues in the future. * Fix all -Wconversion -Warith-conversion reported issues. * Wide char functions need to deal with wint_t and wchar_t and it is guaranteed that a wchar_t can always fit into a wint_t. Add explicit casts to silence the reported warnings. Link: https://www.arm.linux.org.uk/docs/faqs/signedchar.php Link: https://lwn.net/Articles/911914/ Fixes: https://todo.sr.ht/~rjarry/aerc/164 Reported-by: Bence Ferdinandy Suggested-by: Allen Sobot Signed-off-by: Robin Jarry Tested-by: Bence Ferdinandy --- .builds/alpine-edge.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to '.builds/alpine-edge.yml') diff --git a/.builds/alpine-edge.yml b/.builds/alpine-edge.yml index 0f097c53..9433a808 100644 --- a/.builds/alpine-edge.yml +++ b/.builds/alpine-edge.yml @@ -12,7 +12,7 @@ environment: DESTDIR: ./out GOFLAGS: "-tags=notmuch" CC: gcc - CFLAGS: -O2 -g -Wall -Wextra -Werror -Wformat-security -Wstack-protector -fstack-protector-strong -fanalyzer + CFLAGS: -O2 -g -Wall -Wextra -Wconversion -Warith-conversion -Werror -Wformat-security -Wstack-protector -fstack-protector-strong -fanalyzer FILTERS_TEST_PREFIX: valgrind --leak-check=full --error-exitcode=1 tasks: - lint: | -- cgit