Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mfd: ab8500-debugfs: Fix incompatible types in comparison expression issue

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: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>

+1 -1
+1 -1
drivers/mfd/ab8500-debugfs.c
··· 1801 1801 int buf_size, ret; 1802 1802 1803 1803 /* Get userspace string and assure termination */ 1804 - buf_size = min(count, (sizeof(buf)-1)); 1804 + buf_size = min((int)count, (int)(sizeof(buf)-1)); 1805 1805 if (copy_from_user(buf, user_buf, buf_size)) 1806 1806 return -EFAULT; 1807 1807 buf[buf_size] = 0;