Received: by 10.213.65.68 with SMTP id h4csp4235378imn; Tue, 10 Apr 2018 11:25:05 -0700 (PDT) X-Google-Smtp-Source: AIpwx48se2VFuP9M8dcJLHHVyJSZehGSRdMVF1BWm7PyxEgy/pqbS5yNCIMV9tmLANhlek5YmW9f X-Received: by 10.98.182.8 with SMTP id j8mr1249659pff.115.1523384705007; Tue, 10 Apr 2018 11:25:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523384704; cv=none; d=google.com; s=arc-20160816; b=vdhEJituMKpLHjCpZHwSg10uyt6XAk7eN5EUnCcqEyxn63t2RUwJ7kLlv097Ty/qn9 tn4IeVhRwV9a9NEgBIfY1XsPYyvGxH0Xvz6YlyDVlmhb4+/breWySQvkj5DH8svVNS9G CILisTncz9qnMLzNGK0iMJefm/bDMvbk6TUzBvMGlBtn4EkS7xqfMMb7UMcz2tLjvdpO lIIZSZHIemiaPPtGhecPFGwmmgeFz0KQw0/If3lq3QHe/7D2qHPtL88gJgLFlqdl75bL b384Z8o0pLOwLjTdiXYEVZ7yPT+L2Cv1lfMMK5/Nc9G7KHvaOhb8u51WUg7sdNh2sAxP dEXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id :arc-authentication-results; bh=8ZicZUNEfU1hBd09PWucQiyEIy8qqDP+T/cJRw1BGNk=; b=F0YtmxDBPYlFXPy9/Ww18icalv9TRyPL0b15CqZWqXOLtabDRCae/7KiEEncm6ZcI1 /UYzk1o60r+qtb0g3AHcJhRirshEiW15QBCKh75wjepWFlOwzy3ZYSm7K3uxO9uL+szx e531YcMgtKXmbx2A1GKUBM02W3Q0sWNd7E+3VqULYeLTyV60igabR3nMUhc9PN9HWTLW x/hsDEECggP2XmjSMEBpkNIc0v6h+0gXjT0R361+wel1s/qGw+10ny0KireHI+ACe3Hv 9jBlXJkmcVeAQ4WA4m+keaMt2aduDYQQY8xr2175gcpUUAC8d2yc81AFLz/FAhzl5uOh lN0Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e6si2182386pgn.473.2018.04.10.11.24.26; Tue, 10 Apr 2018 11:25:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752184AbeDJSUA (ORCPT + 99 others); Tue, 10 Apr 2018 14:20:00 -0400 Received: from smtprelay0047.hostedemail.com ([216.40.44.47]:45272 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751961AbeDJST6 (ORCPT ); Tue, 10 Apr 2018 14:19:58 -0400 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay07.hostedemail.com (Postfix) with ESMTP id B82F0181D340F; Tue, 10 Apr 2018 18:19:57 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::::::::::::::::,RULES_HIT:41:355:379:541:800:960:967:973:982:988:989:1260:1277:1311:1313:1314:1345:1359:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2393:2525:2559:2563:2682:2685:2828:2859:2933:2937:2939:2942:2945:2947:2951:2954:3022:3138:3139:3140:3141:3142:3352:3865:3866:3867:3868:3870:3871:3874:3934:3936:3938:3941:3944:3947:3950:3953:3956:3959:5007:8603:9025:10004:10400:10848:11658:11914:12043:12048:12555:12740:12760:12895:12986:13069:13095:13161:13229:13255:13311:13357:13439:14181:14394:14659:14721:21080:21433:21627:30054:30060:30070,0,RBL:error,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:22,LUA_SUMMARY:none X-HE-Tag: offer42_3995c20971129 X-Filterd-Recvd-Size: 2801 Received: from XPS-9350.home (unknown [47.151.150.235]) (Authenticated sender: joe@perches.com) by omf03.hostedemail.com (Postfix) with ESMTPA; Tue, 10 Apr 2018 18:19:55 +0000 (UTC) Message-ID: <95477c93db187bab6da8a8ba7c57836868446179.camel@perches.com> Subject: [PATCH] checkpatch: Add a --strict test for structs with bool member definitions From: Joe Perches To: Peter Zijlstra , "Rafael J. Wysocki" , Andrew Morton , Andy Whitcroft Cc: yuankuiz@codeaurora.org, Linux PM , "Rafael J. Wysocki" , Frederic Weisbecker , Thomas Gleixner , paulmck@linux.vnet.ibm.com, Ingo Molnar , Len Brown , Linux Kernel Mailing List Date: Tue, 10 Apr 2018 11:19:54 -0700 In-Reply-To: References: <891d4f632fbff5052e11f2d0b6fac35d@codeaurora.org> <20180410123305.GF4082@hirez.programming.kicks-ass.net> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.28.0-4 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org A struct with a bool member can have different sizes on various architectures because neither bool size nor alignment is standardized. So emit a message on the use of bool in structs only in .h files and not .c files. There is the real possibility that this test could have a false positive when a bool is declared as an automatic, so limit the test to .h files where the only false positive is for declarations in static inline functions. Signed-off-by: Joe Perches Suggested-by: Peter Zijlstra --- scripts/checkpatch.pl | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index e16d6713f236..24618dffc5cb 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -6257,6 +6257,13 @@ sub process { "Avoid using bool as bitfield. Prefer bool bitfields as unsigned int or u<8|16|32>\n" . $herecurr); } +# check for bool use in .h files + if ($realfile =~ /\.h$/ && + $sline =~ /^.\s+bool\s*$Ident\s*(?::\s*d+\s*)?;/) { + CHK("BOOL_MEMBER", + "Avoid using bool structure members because of possible alignment issues - see: https://lkml.org/lkml/2017/11/21/384\n" . $herecurr); + } + # check for semaphores initialized locked if ($line =~ /^.\s*sema_init.+,\W?0\W?\)/) { WARN("CONSIDER_COMPLETION", -- 2.15.0