]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
staging: fbtft: fix strncmp() size warning
authorYueHaibing <yuehaibing@huawei.com>
Tue, 18 Dec 2018 14:28:21 +0000 (22:28 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 19 Dec 2018 07:29:28 +0000 (08:29 +0100)
strncmp() stops comparing when either the end of one of the first two
arguments is reached or when 'n' characters have been compared, whichever
comes first.That means that strncmp(s1, s2, n) is equivalent to
strcmp(s1, s2) if n exceeds the length of s1 or the length of s2.

This patch avoids that the following warning is reported by smatch:

drivers/staging/fbtft/fbtft_device.c:1458
 fbtft_device_init() error: strncmp() '"list"' too small (5 vs 32)

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/fbtft/fbtft_device.c

index 50e97da993e791ce45ecd7ff1b5a2d7964c44b53..046f9d355ecb15d8c94cb0e63403af87f3ee6be6 100644 (file)
@@ -1455,7 +1455,7 @@ static int __init fbtft_device_init(void)
        }
 
        /* name=list lists all supported displays */
-       if (strncmp(name, "list", FBTFT_GPIO_NAME_SIZE) == 0) {
+       if (strcmp(name, "list") == 0) {
                pr_info("Supported displays:\n");
 
                for (i = 0; i < ARRAY_SIZE(displays); i++)