Skip to contentSkip to conversation

kbuild-treat-char-as-always-unsigned.patch removed from -mm tree

merged Andrew Morton 1 participant 1 message Oct 21, 2022

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: kbuild: treat char as always unsigned
has been removed from the -mm tree. Its filename was
kbuild-treat-char-as-always-unsigned.patch

This patch was dropped because it was merged into mainline or a subsystem tree

------------------------------------------------------
From: "Jason A. Donenfeld" <[email protected]>
Subject: kbuild: treat char as always unsigned
Date: Wed, 19 Oct 2022 14:30:34 -0600

Recently, some compile-time checking I added to the clamp_t family of functions triggered a build error when a poorly written driver was compiled on ARM, because the driver assumed that the naked char type is signed, but ARM treats it as unsigned, and the C standard says it's architecture-dependent.

I doubt this particular driver is the only instance in which unsuspecting authors make assumptions about char with no signed or unsigned specifier. We were lucky enough this time that that driver used clamp_t(char, negative_value, positive_value), so the new checking code found it, and I've sent a patch to fix it, but there are likely other places lurking that won't be so easily unearthed.

So let's just eliminate this particular variety of heisensign bugs entirely. Set -funsigned-char globally, so that gcc makes the type unsigned on all architectures.

This will break things in some places and fix things in others, so this will likely cause a bit of churn while reconciling the type misuse.

---

 Makefile |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Makefile renamed from Makefile~kbuild-treat-char-as-always-unsigned +1 -1
@@ -562,7 +562,7 @@ KBUILD_AFLAGS   := -D__ASSEMBLY__ -fno-P
 KBUILD_CFLAGS   := -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs \
 		   -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE \
 		   -Werror=implicit-function-declaration -Werror=implicit-int \
-		   -Werror=return-type -Wno-format-security \
+		   -Werror=return-type -Wno-format-security -funsigned-char \
 		   -std=gnu11
 KBUILD_CPPFLAGS := -D__KERNEL__
 KBUILD_RUSTFLAGS := $(rust_common_flags) \

_

Patches currently in -mm which might be from [email protected] are

wifi-rt2x00-use-explicitly-signed-type-for-clamping.patch minmax-sanity-check-constant-bounds-when-clamping.patch minmax-clamp-more-efficiently-by-avoiding-extra-comparison.patch