Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp5012668ybl; Wed, 22 Jan 2020 08:41:33 -0800 (PST) X-Google-Smtp-Source: APXvYqx7DaACsJj8SXmwTyGBix2ZSGEffOEtA/K7uWYIgHwruee3hj3kmFTRrPyO4x9G+sJrsRF3 X-Received: by 2002:aca:3241:: with SMTP id y62mr7340902oiy.31.1579711293017; Wed, 22 Jan 2020 08:41:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579711293; cv=none; d=google.com; s=arc-20160816; b=F/bIQYuxux6DJADwBLGANTAtvumkW7Bn2hK1JjW5eGQTNE7Iazsrq93q9Vbc5rts05 eJQQVMjQinijOjBbQd6VJPMFcY7FFbnOPLxo+2iZQFOSP5rjcRSPAN6/ld4rltYQz1kj 9w9vXCPX0HKtMSKP3IzwwB4OjNi23b79btxdevf+7o0EvqIjKYd+/AK6YwmP7D8U37Xa BHf5UB6+AyFLrdh3d67GdgBHVCwthZ3q+P3tH4GjzTGCPzEm00HUeCSu1dyXs6EBNgHW UeYArOpLnvJEfA9HoXHwqNF4mCChiXudRB1KtCv9mrXfUoNRZT3HCrgSRo7FXk05dhYi QpiA== 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:message-id:date:subject:cc:to:from :dkim-signature; bh=vYv6iD1pZWL1+3b/sqFs+t3oIl63DwgZ1fMx7OzmI8k=; b=fY9hJG7HRCYiZ9uKB7C9TjvQjWoZ/f9jVBhLlOqW2nom7b+NwW3gZwggDr+U91vAX1 vH4INnPdsBdftrbBzTwapFauczI/CwD5sBmwhZO+QiQfPVGhtkliAsEj27ZeGr2oGdeW m/ZLYmBWcmmAIa/wER36C0UXv5Pomvgiv4yJELF/ywcn+hTFrl6/vv+giYghSSRZac5t ViYHwtnMUfaqqb0KYQH4Xs+JNDOqtWGCQImWGqlhcyBBwdXljs/ziB12oFy53meXvPsB W/V0JPl0T2Ug0cfEWefwLguDiJU6gGa2fj5s5xGmfEzpf16zAxCPIXfHRMlHj++jOKMi gljA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=EI0Q8ynN; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z14si20288863oih.89.2020.01.22.08.41.21; Wed, 22 Jan 2020 08:41:33 -0800 (PST) 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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=EI0Q8ynN; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727453AbgAVQjy (ORCPT + 99 others); Wed, 22 Jan 2020 11:39:54 -0500 Received: from mail-wm1-f65.google.com ([209.85.128.65]:56068 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725802AbgAVQjy (ORCPT ); Wed, 22 Jan 2020 11:39:54 -0500 Received: by mail-wm1-f65.google.com with SMTP id q9so7493575wmj.5 for ; Wed, 22 Jan 2020 08:39:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vYv6iD1pZWL1+3b/sqFs+t3oIl63DwgZ1fMx7OzmI8k=; b=EI0Q8ynN00aMv8cpcGbqfUnTvFCOd16NoztgS/oTZTy6Ne8E6SUxVb4/7UI9lYmId9 Cziv+fQHAwGZTTu0LF0TAbFDjnZxACh37XQF8Wi/UktzuUtZpK+x/uuFgUMhu+KPV8Sc MA/M5t1xZv/s5Ubc4Dvo7H8Wg4WXWS0S78roqRmWW+v7dfwOsFMSoJ4QjXm6fOVMwTqV DnbSzjn5kwPPUPmoaYnT+3NLKGP52NiPuJEg2liN+se7J4TFCplfNMrCKH93viwuIeNx PuxrGwURnqBQRRadotrqef6Ht4GTtwWK9cHCwsHzXVT2rcq9h2vywjtNpH1vaJfVdH+y ybTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vYv6iD1pZWL1+3b/sqFs+t3oIl63DwgZ1fMx7OzmI8k=; b=MDFWYLkJPvuTEFXAK4aWiVU4vWAIs6JZ2RQSoWIExXT41jo3FnsqWm2kRTZsG/itrV s2maxOlXC7GkDvvKX3LQT0i+KlGhBgjK6ZTYfngj9QkvsZR/FZxFuEgsAL7+c5OaZGQI cSXO/JFoH7eyShyqJhLBproNyVRF2Ql6vrCJiq/RkKNeVH5c+Za4zZS5Hi143kFrDc5K w7pKwJQnQMbMngA+QsQt2juG9TkQzvTMV6RYXh6d4HfXpqtSQyw4QhaUKFekS8VBzUh7 68HyuP+dz7lZtl9G8J1JwGATX1KjomYHPRfAxA1jDB8mYRxfA2CF2eEnB7SaFcAmL2Gl igzw== X-Gm-Message-State: APjAAAXgMG/bGYEnfNGCQOqxYvohsm29++zspjAHttk9r0XPV+H6eMX5 t6vWSIn9zIMfr00TAZGgT0uFqyMSVrM= X-Received: by 2002:a7b:cd87:: with SMTP id y7mr3175120wmj.61.1579711192694; Wed, 22 Jan 2020 08:39:52 -0800 (PST) Received: from localhost.localdomain (lneuilly-657-1-69-3.w80-11.abo.wanadoo.fr. [80.11.53.3]) by smtp.gmail.com with ESMTPSA id j2sm4908557wmk.23.2020.01.22.08.39.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jan 2020 08:39:51 -0800 (PST) From: Antonio Borneo To: Joe Perches , Andy Whitcroft Cc: Antonio Borneo , linux-kernel@vger.kernel.org Subject: [PATCH V3] checkpatch: fix multiple const * types Date: Wed, 22 Jan 2020 17:38:50 +0100 Message-Id: <20200122163852.124417-1-borneo.antonio@gmail.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20190508122721.7513-1-borneo.antonio@gmail.com> References: <20190508122721.7513-1-borneo.antonio@gmail.com> <4517dfca6c4692b28c4914410f475d3f521cd230.camel@perches.com> <20190508174347.13901-1-borneo.antonio@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit 1574a29f8e76 ("checkpatch: allow multiple const * types") claims to support repetition of pattern "const *", but it actually allows only one extra instance. Check the following lines int a(char const * const x[]); int b(char const * const *x); int c(char const * const * const x[]); int d(char const * const * const *x); with command ./scripts/checkpatch.pl --show-types -f filename to find that only the first line passes the test, while a warning is triggered by the other 3 lines: WARNING:FUNCTION_ARGUMENTS: function definition argument 'char const * const' should also have an identifier name The reason is that the pattern match halts at the second asterisk in the line, thus the remaining text starting with asterisk fails to match a valid name for a variable. Fixed by replacing "?" (Match 1 or 0 times) with "{0,4}" (Match no more than 4 times) in the regular expression. Fix also the similar test for types in unusual order. Signed-off-by: Antonio Borneo Fixes: 1574a29f8e76 ("checkpatch: allow multiple const * types") --- V1->V2 use a max match {0,4} instead of *, to limit the memory used by perl V2->V3 rebased --- scripts/checkpatch.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index a63380c6b0d2..30da08d9646a 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -804,12 +804,12 @@ sub build_types { }x; $Type = qr{ $NonptrType - (?:(?:\s|\*|\[\])+\s*const|(?:\s|\*\s*(?:const\s*)?|\[\])+|(?:\s*\[\s*\])+)? + (?:(?:\s|\*|\[\])+\s*const|(?:\s|\*\s*(?:const\s*)?|\[\])+|(?:\s*\[\s*\])+){0,4} (?:\s+$Inline|\s+$Modifier)* }x; $TypeMisordered = qr{ $NonptrTypeMisordered - (?:(?:\s|\*|\[\])+\s*const|(?:\s|\*\s*(?:const\s*)?|\[\])+|(?:\s*\[\s*\])+)? + (?:(?:\s|\*|\[\])+\s*const|(?:\s|\*\s*(?:const\s*)?|\[\])+|(?:\s*\[\s*\])+){0,4} (?:\s+$Inline|\s+$Modifier)* }x; $Declare = qr{(?:$Storage\s+(?:$Inline\s+)?)?$Type}; -- 2.25.0