Skip to contentSkip to conversation

platform/x86: intel_pmc_core: Fix "unsigned 'ret' is never less than zero" smatch warning

PATCH Applied Hans de Goede 1 participant 2 messages Apr 19, 2021 – Apr 20, 2021 x86 platform drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 platform/x86: intel_pmc_core: Fix "unsigned 'ret' is never less than zero" smatch warning

Change the type of ret form a size_t to a ssize_t, matching the prototype of simple_write_to_buffer(), fixing this warning reported by smatch:

drivers/platform/x86/intel_pmc_core.c:1369 pmc_core_lpm_latch_mode_write() warn: unsigned 'ret' is never less than zero.

Fixes 8074a79fad2e ("platform/x86: intel_pmc_core: Add option to set/clear LPM mode")
Cc David E. Box <[email protected]>
---
 drivers/platform/x86/intel_pmc_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/x86/intel_pmc_core.c +1 -1
index 3ae00ac85c75..d174aeb492e0 100644
@@ -1360,7 +1360,7 @@ static ssize_t pmc_core_lpm_latch_mode_write(struct file *file,
 	struct pmc_dev *pmcdev = s->private;
 	bool clear = false, c10 = false;
 	unsigned char buf[8];
-	size_t ret;
+	ssize_t ret;
 	int idx, m, mode;
 	u32 reg;
 
Signature · 1 line
2.31.1
author Applied
#1 lore raw

Hi,

Quoted 9 lines · Hans de Goede

Change the type of ret form a size_t to a ssize_t, matching the prototype of simple_write_to_buffer(), fixing this warning reported by smatch:

drivers/platform/x86/intel_pmc_core.c:1369 pmc_core_lpm_latch_mode_write() warn: unsigned 'ret' is never less than zero.

Fixes 8074a79fad2e ("platform/x86: intel_pmc_core: Add option to set/clear LPM mode")
Cc David E. Box <[email protected]>

I've applied this to my review-hans branch now.

Regards,

Hans

Quoted 18 lines
---
 drivers/platform/x86/intel_pmc_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/x86/intel_pmc_core.c +1 -1
index 3ae00ac85c75..d174aeb492e0 100644
@@ -1360,7 +1360,7 @@ static ssize_t pmc_core_lpm_latch_mode_write(struct file *file,
 	struct pmc_dev *pmcdev = s->private;
 	bool clear = false, c10 = false;
 	unsigned char buf[8];
-	size_t ret;
+	ssize_t ret;
 	int idx, m, mode;
 	u32 reg;