From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751602AbdBODgd (ORCPT ); Tue, 14 Feb 2017 22:36:33 -0500 Received: from smtprelay0189.hostedemail.com ([216.40.44.189]:56357 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751417AbdBODgc (ORCPT ); Tue, 14 Feb 2017 22:36:32 -0500 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::,RULES_HIT:41:355:379:541:560:599:960:968:973:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1540:1593:1594:1711:1730:1747:1777:1792:2393:2559:2562:2828:2898:3138:3139:3140:3141:3142:3352:3622:3865:3866:3867:3868:3870:3871:4321:5007:8660:10004:10400:10848:11026:11232:11473:11658:11914:12043:12740:12760:12895:13069:13148:13230:13311:13357:13439:14659:14721:21080:21434:30029:30034:30054:30070:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:1,LUA_SUMMARY:none X-HE-Tag: fire50_72f82d6702c19 X-Filterd-Recvd-Size: 1773 Message-ID: <1487129788.6214.41.camel@perches.com> Subject: Re: [PATCH v2 2/3] staging: fbtft: Replace magic number with constant From: Joe Perches To: "Tobin C. Harding" , Thomas Petazzoni , noralf@tronnes.org Cc: Greg Kroah-Hartman , devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Date: Tue, 14 Feb 2017 19:36:28 -0800 In-Reply-To: <1487129245-24970-3-git-send-email-me@tobin.cc> References: <1487129245-24970-1-git-send-email-me@tobin.cc> <1487129245-24970-3-git-send-email-me@tobin.cc> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.22.3-0ubuntu0.1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2017-02-15 at 14:27 +1100, Tobin C. Harding wrote: > 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. OK thanks, as well: > diff --git 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) { Maybe change this to: if (strncmp(name, displays[i].name, SPI_NAME_SIZE) != 0) continue; and reduce the indentation of the rest of the block.