[<prev] [next>] [day] [month] [year] [list]
Message-ID: <C2885DC275589FDD+20250219115307.194770-1-wangyuli@uniontech.com>
Date: Wed, 19 Feb 2025 19:53:07 +0800
From: WangYuli <wangyuli@...ontech.com>
To: chenhuacai@...nel.org,
kernel@...0n.name
Cc: wangyuli@...ontech.com,
maobibo@...ngson.cn,
guanwentao@...ontech.com,
loongarch@...ts.linux.dev,
linux-kernel@...r.kernel.org,
zhanjun@...ontech.com,
niecheng1@...ontech.com,
chenlinxuan@...ontech.com
Subject: [PATCH] LoongArch: acpi: Conditional apic_id vs CONFIG_NR_CPUS comparison
The apic_id here, as declared as a u8 (unsigned char) in struct
acpi_srat_cpu_affinity of acpi/actbl3.h, has a range up to 255.
Evidently, if CONFIG_NR_CPUS becomes 256 or more, the check
"apic_id >= CONFIG_NR_CPUS" will always be false, which will produce
a compiler warning.
Only compile this code if CONFIG_NR_CPUS is at most 255 consequently.
Fix follow error with clang-18 when W=1e:
arch/loongarch/kernel/acpi.c:302:18: error: result of comparison of constant 256 with expression of type 'u8' (aka 'unsigned char') is always false [-Werror,-Wtautological-constant-out-of-range-compare]
302 | if (pa->apic_id >= CONFIG_NR_CPUS) {
| ~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~
1 error generated.
Signed-off-by: Yuli Wang <wangyuli@...ontech.com>
---
arch/loongarch/kernel/acpi.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/arch/loongarch/kernel/acpi.c b/arch/loongarch/kernel/acpi.c
index 2bb3bc42e6ed..ee471a80763e 100644
--- a/arch/loongarch/kernel/acpi.c
+++ b/arch/loongarch/kernel/acpi.c
@@ -299,11 +299,17 @@ acpi_numa_processor_affinity_init(struct acpi_srat_cpu_affinity *pa)
return;
}
+/*
+ * apic_id's type is u8.
+ * Conditionally skip this check to silence compiler warnings.
+ */
+#if CONFIG_NR_CPUS < 256
if (pa->apic_id >= CONFIG_NR_CPUS) {
pr_info("SRAT: PXM %u -> CPU 0x%02x -> Node %u skipped apicid that is too big\n",
pxm, pa->apic_id, node);
return;
}
+#endif /* CONFIG_NR_CPUS < 256 */
early_numa_add_cpu(pa->apic_id, node);
--
2.47.2
Powered by blists - more mailing lists