linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 -next] staging: fbtft: use strcmp() instead of strncmp() for
@ 2018-12-18 13:25 YueHaibing
  2018-12-18 13:37 ` Dan Carpenter
  0 siblings, 1 reply; 3+ messages in thread
From: YueHaibing @ 2018-12-18 13:25 UTC (permalink / raw)
  To: devel, gregkh, leobras.c, radek.dostal
  Cc: linux-kernel, linux-fbdev, dri-devel, YueHaibing

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>
---
v2: fix patch title
---
 drivers/staging/fbtft/fbtft_device.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/fbtft/fbtft_device.c b/drivers/staging/fbtft/fbtft_device.c
index 50e97da..0e995028 100644
--- a/drivers/staging/fbtft/fbtft_device.c
+++ b/drivers/staging/fbtft/fbtft_device.c
@@ -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++)
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2 -next] staging: fbtft: use strcmp() instead of strncmp() for
  2018-12-18 13:25 [PATCH v2 -next] staging: fbtft: use strcmp() instead of strncmp() for YueHaibing
@ 2018-12-18 13:37 ` Dan Carpenter
  2018-12-18 13:46   ` YueHaibing
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2018-12-18 13:37 UTC (permalink / raw)
  To: YueHaibing
  Cc: devel, linux-fbdev, leobras.c, radek.dostal, gregkh, linux-kernel,
	dri-devel

On Tue, Dec 18, 2018 at 09:25:08PM +0800, YueHaibing wrote:
> 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>
> ---
> v2: fix patch title

v2 is worse than v1...

v1 is a little long but I wouldn't have complained about it.

Please assume that the subject and the commit message are separate
things.  Take a look how the patch description reads on marc.info:

https://marc.info/?l=linux-driver-devel&m\x154513957719226&w=2

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2 -next] staging: fbtft: use strcmp() instead of strncmp() for
  2018-12-18 13:37 ` Dan Carpenter
@ 2018-12-18 13:46   ` YueHaibing
  0 siblings, 0 replies; 3+ messages in thread
From: YueHaibing @ 2018-12-18 13:46 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: devel, gregkh, leobras.c, radek.dostal, linux-fbdev, linux-kernel,
	dri-devel

On 2018/12/18 21:37, Dan Carpenter wrote:
> On Tue, Dec 18, 2018 at 09:25:08PM +0800, YueHaibing wrote:
>> 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>
>> ---
>> v2: fix patch title
> 
> v2 is worse than v1...

Yes, ...., I messed up.

I will fix it.

> 
> v1 is a little long but I wouldn't have complained about it.
> 
> Please assume that the subject and the commit message are separate
> things.  Take a look how the patch description reads on marc.info:
> 
> https://marc.info/?l=linux-driver-devel&m\x154513957719226&w=2
> 
> regards,
> dan carpenter
> 
> 
> .
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-12-18 13:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-12-18 13:25 [PATCH v2 -next] staging: fbtft: use strcmp() instead of strncmp() for YueHaibing
2018-12-18 13:37 ` Dan Carpenter
2018-12-18 13:46   ` YueHaibing

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).