Skip to contentSkip to conversation

thermal: Use symbolic constant for UUID prefix comparison

PATCH Applied Kaushlendra Kumar 2 participants 2 messages Oct 30, 2025 – Nov 12, 2025 Thermal

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 thermal: Use symbolic constant for UUID prefix comparison

Replace sizeof() with a symbolic constant for UUID matching to maintain existing ABI behavior while improving code clarity. The current behavior of comparing only the first 7 characters is sufficient to distinguish all UUIDs and changing to full string comparison would alter the kernel ABI, potentially breaking existing userspace applications.

Use a defined constant to make the truncated comparison explicit and maintainable.

---
Changes in v2:
- Use symbolic constant instead of strlen() to maintain existing ABI behavior as review feedback

 drivers/thermal/intel/int340x_thermal/int3400_thermal.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/thermal/intel/int340x_thermal/int3400_thermal.c +3 -1
index 908cc1bf57f1..128556632685 100644
@@ -16,6 +16,8 @@
 #define INT3400_ODVP_CHANGED 0x88
 #define INT3400_KEEP_ALIVE 0xA0
 #define INT3400_FAKE_TEMP (20 * 1000) /* faked temp sensor with 20C */
+/* UUID prefix length for comparison - sufficient for all UUIDs */
+#define INT3400_UUID_PREFIX_LEN 7
 
 enum int3400_thermal_uuid {
 	INT3400_THERMAL_ACTIVE = 0,
@@ -199,7 +201,7 @@ static ssize_t current_uuid_store(struct device *dev,
 
 	for (i = 0; i < INT3400_THERMAL_MAXIMUM_UUID; ++i) {
 		if (!strncmp(buf, int3400_thermal_uuids[i],
-			     sizeof(int3400_thermal_uuids[i]) - 1)) {
+			     INT3400_UUID_PREFIX_LEN)) {
 			/*
 			 * If we have a list of supported UUIDs, make sure
 			 * this one is supported.
Signature · 1 line
2.34.1
maintainer Applied
#1 lore raw
Quoted 33 lines · Kaushlendra Kumar

Replace sizeof() with a symbolic constant for UUID matching to maintain existing ABI behavior while improving code clarity. The current behavior of comparing only the first 7 characters is sufficient to distinguish all UUIDs and changing to full string comparison would alter the kernel ABI, potentially breaking existing userspace applications.

Use a defined constant to make the truncated comparison explicit and maintainable.

---
Changes in v2:
- Use symbolic constant instead of strlen() to maintain existing ABI behavior as review feedback

 drivers/thermal/intel/int340x_thermal/int3400_thermal.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/thermal/intel/int340x_thermal/int3400_thermal.c +2 -0
index 908cc1bf57f1..128556632685 100644
@@ -16,6 +16,8 @@
 #define INT3400_ODVP_CHANGED 0x88
 #define INT3400_KEEP_ALIVE 0xA0
 #define INT3400_FAKE_TEMP (20 * 1000) /* faked temp sensor with 20C */
+/* UUID prefix length for comparison - sufficient for all UUIDs */
+#define INT3400_UUID_PREFIX_LEN 7
 
 enum int3400_thermal_uuid {
        INT3400_THERMAL_ACTIVE = 0,

drivers/thermal/intel/int340x_thermal/int3400_thermal.c static ssize_t current_uuid_store(struct device *dev,

Quoted 9 lines
drivers/thermal/intel/int340x_thermal/int3400_thermal.c +1 -2
@@ -199,7 +201,7 @@ static ssize_t current_uuid_store(struct device *dev,
 
        for (i = 0; i < INT3400_THERMAL_MAXIMUM_UUID; ++i) {
                if (!strncmp(buf, int3400_thermal_uuids[i],
-                            sizeof(int3400_thermal_uuids[i]) - 1)) {
+                            INT3400_UUID_PREFIX_LEN)) {
                        /*
                         * If we have a list of supported UUIDs, make sure
                         * this one is supported.
--

Applied as 6.19 material, thanks!