From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S940766AbdAJODa (ORCPT ); Tue, 10 Jan 2017 09:03:30 -0500 Received: from s3.sipsolutions.net ([5.9.151.49]:51748 "EHLO sipsolutions.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752086AbdAJOD0 (ORCPT ); Tue, 10 Jan 2017 09:03:26 -0500 From: Johannes Berg To: Andrew Morton Cc: Joe Perches , linux-kernel@vger.kernel.org, Johannes Berg Subject: [PATCH] checkpatch: don't warn on every struct without const_structs file Date: Tue, 10 Jan 2017 15:03:18 +0100 Message-Id: <20170110140318.737-1-johannes@sipsolutions.net> X-Mailer: git-send-email 2.9.3 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Johannes Berg The script says that it won't warn: "No structs that should be const will be found [...]" but then that doesn't work and it warns on every single struct instead, since the regular expression ends up empty. Fix that by checking that it's not empty first. Fixes: bf1fa1dae68e ("checkpatch: externalize the structs that should be const") Signed-off-by: Johannes Berg --- scripts/checkpatch.pl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index a8368d1c4348..722a319acec5 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -6010,7 +6010,8 @@ sub process { } # check for various structs that are normally const (ops, kgdb, device_tree) - if ($line !~ /\bconst\b/ && + if ($const_structs ne "" && + $line !~ /\bconst\b/ && $line =~ /\bstruct\s+($const_structs)\b/) { WARN("CONST_STRUCT", "struct $1 should normally be const\n" . -- 2.9.3