Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1581031

[PATCH v2 2/3] staging: fbtft: Replace magic number with constant

From "Tobin C. Harding" <me@tobin.cc>
Newsgroups linux.kernel
Subject [PATCH v2 2/3] staging: fbtft: Replace magic number with constant
Date 2017-02-15 04:30 +0100
Message-ID <taYs2-2jy-9@gated-at.bofh.it> (permalink)
References <taYs1-2jy-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Current call to strncmp() uses a magic number. There is a compile
time constant defined for this buffer, included and used already at
other sites in the file.

Remove magic number. Replace with pre-existing compile time constant.

Signed-off-by: Tobin C. Harding <me@tobin.cc>
---
 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 7b7223b..5fbdd37 100644
--- a/drivers/staging/fbtft/fbtft_device.c
+++ b/drivers/staging/fbtft/fbtft_device.c
@@ -1489,7 +1489,7 @@ static int __init fbtft_device_init(void)
 	}
 
 	for (i = 0; i < ARRAY_SIZE(displays); i++) {
-		if (strncmp(name, displays[i].name, 32) == 0) {
+		if (strncmp(name, displays[i].name, SPI_NAME_SIZE) == 0) {
 			if (displays[i].spi) {
 				spi = displays[i].spi;
 				spi->chip_select = cs;
-- 
2.7.4

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v2 0/3] staging: fbtft: Fix buffer overflow vulnerability "Tobin C. Harding" <me@tobin.cc> - 2017-02-15 04:30 +0100
  [PATCH v2 2/3] staging: fbtft: Replace magic number with constant "Tobin C. Harding" <me@tobin.cc> - 2017-02-15 04:30 +0100
    Re: [PATCH v2 2/3] staging: fbtft: Replace magic number with  constant Joe Perches <joe@perches.com> - 2017-02-15 04:40 +0100
  [PATCH v2 3/3] staging: fbtft: Add check on strlcpy() return value "Tobin C. Harding" <me@tobin.cc> - 2017-02-15 04:30 +0100

csiph-web