diff mbox series

[07/10] mfd: ab8500-debugfs: Fix incompatible types in comparison expression issue

Message ID 20200624150704.2729736-8-lee.jones@linaro.org
State Accepted
Commit ddb6b26c4102aab886277b2ca3c027b4976d819b
Headers show
Series [01/10] mfd: twl4030-irq: Fix incorrect type in assignment warning | expand

Commit Message

Lee Jones June 24, 2020, 3:07 p.m. UTC
Smatch reports:

 drivers/mfd/ab8500-debugfs.c:1804:20: error: incompatible types in comparison expression (different type sizes):
 drivers/mfd/ab8500-debugfs.c:1804:20:    unsigned int *
 drivers/mfd/ab8500-debugfs.c:1804:20:    unsigned long *

This is due to mixed types being compared in a min() comparison.  Fix
this by treating values as signed and casting them to the same type
as the receiving variable.

Cc: <stable@vger.kernel.org>
Cc: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>

---
 drivers/mfd/ab8500-debugfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

-- 
2.25.1

Comments

Linus Walleij July 7, 2020, 12:34 p.m. UTC | #1
On Wed, Jun 24, 2020 at 5:07 PM Lee Jones <lee.jones@linaro.org> wrote:

> Smatch reports:

>

>  drivers/mfd/ab8500-debugfs.c:1804:20: error: incompatible types in comparison expression (different type sizes):

>  drivers/mfd/ab8500-debugfs.c:1804:20:    unsigned int *

>  drivers/mfd/ab8500-debugfs.c:1804:20:    unsigned long *

>

> This is due to mixed types being compared in a min() comparison.  Fix

> this by treating values as signed and casting them to the same type

> as the receiving variable.

>

> Cc: <stable@vger.kernel.org>

> Cc: Linus Walleij <linus.walleij@linaro.org>

> Signed-off-by: Lee Jones <lee.jones@linaro.org>


Reviewed-by: Linus Walleij <linus.walleij@linaro.org>


Yours,
Linus Walleij
diff mbox series

Patch

diff --git a/drivers/mfd/ab8500-debugfs.c b/drivers/mfd/ab8500-debugfs.c
index 1a9a3414d4fa8..6d1bf7c3ca3b1 100644
--- a/drivers/mfd/ab8500-debugfs.c
+++ b/drivers/mfd/ab8500-debugfs.c
@@ -1801,7 +1801,7 @@  static ssize_t ab8500_hwreg_write(struct file *file,
 	int buf_size, ret;
 
 	/* Get userspace string and assure termination */
-	buf_size = min(count, (sizeof(buf)-1));
+	buf_size = min((int)count, (int)(sizeof(buf)-1));
 	if (copy_from_user(buf, user_buf, buf_size))
 		return -EFAULT;
 	buf[buf_size] = 0;