From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753603AbdBUXwf (ORCPT ); Tue, 21 Feb 2017 18:52:35 -0500 Received: from out4-smtp.messagingengine.com ([66.111.4.28]:43713 "EHLO out4-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753513AbdBUXwW (ORCPT ); Tue, 21 Feb 2017 18:52:22 -0500 X-ME-Sender: X-Sasl-enc: W51XAGSo2itfqv6B7RS970DYIszxbAgJD8uRaB9n7gG+ 1487721140 Date: Wed, 22 Feb 2017 10:52:18 +1100 From: "Tobin C. Harding" To: Joe Perches Cc: Andy Whitcroft , linux-kernel@vger.kernel.org Subject: Re: checkpatch suspected false positive Message-ID: <20170221235218.GA30902@eros> References: <20170221230148.GA25711@eros> <1487719162.2853.41.camel@perches.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1487719162.2853.41.camel@perches.com> X-Mailer: Mutt 1.5.24 (2015-08-30) User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 21, 2017 at 03:19:22PM -0800, Joe Perches wrote: > On Wed, 2017-02-22 at 10:01 +1100, Tobin C. Harding wrote: > > Checkpatch may be giving a false positive of type CONST_STRUCT when > > parsing files in drivers/staging/comedi/drivers. > > > > $ pwd > > build/kernel/linux-trees/gregKH/staging/ > > > > $ cd drivers/staging/comedi/drivers > > > > $ checkpatch --terse --show-types *.c | grep CONST_STRUCT > > addi_apci_3501.c:97: WARNING:CONST_STRUCT: struct comedi_lrange should normally be const > > das16.c:972: WARNING:CONST_STRUCT: struct comedi_lrange should normally be const > > das16.c:1006: WARNING:CONST_STRUCT: struct comedi_lrange should normally be const > > jr3_pci.c:659: WARNING:CONST_STRUCT: struct comedi_lrange should normally be const > > jr3_pci.c:667: WARNING:CONST_STRUCT: struct comedi_lrange should normally be const > > jr3_pci.c:668: WARNING:CONST_STRUCT: struct comedi_lrange should normally be const > > ni_670x.c:212: WARNING:CONST_STRUCT: struct comedi_lrange should normally be const > > checkpatch is brainless, it just looks for patterns > that are atypical. > > $ git grep -E "struct\s+comedi_lrange\b" | wc -l > 223 > $ git grep -E "const\s+struct\s+comedi_lrange\b" | wc -l > 215 > > So, yes, that struct is normally const. > Normally doesn't mean always or has to be. > Cheers Joe. I'm sure this is not the first time you have explained that. Would it be a good idea to add some documentation (in Documentation/process) about checkpatch gotchas. Perhaps we could save some people some time if every newbie didn't have to make the same mistakes (or ask the same questions). The first two could be; 1. Don't fix line over 80 warnings if it does not objectively make the code more readable (see coding-style.rst, grep for 'Statements longer than 80 columns'). 2. Warning struct foo should normally be const ... description of how checkpatch decides this warning is necessary. thanks, Tobin.