Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp10555428pxu; Wed, 30 Dec 2020 05:49:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJxF20VXFZdo+d7bPqLKgfu3LLz1mj4Fk2v5vyx/r31nvbCTNuBMi95fa4i42DDPo7PZQv5k X-Received: by 2002:a05:6402:8da:: with SMTP id d26mr48890513edz.157.1609336171681; Wed, 30 Dec 2020 05:49:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609336171; cv=none; d=google.com; s=arc-20160816; b=uLu2yKg1BoMsR6nJ2UUwTXAE3RAe0OPmc/2cu4+/UEdIERQhCe8aPmcaoB8WggJCWb w2imtrRfFS4jyCJZ2J5OkJmAi1Zng+YYiMqIv5l32kmYQAUUZNt/hgihvXjAad2kzIxw zloJxEoLWFC77phKmnbciBC8csOKcekvF+w3o4Lbtrn20DB46WTkFig24CkF1rf99wON YLP+iQs+Z3RVKjuvlWYDd9TVql6THgxfImcx2fp6sSan4QF9JMeNLAiAUc8E1PFFJy3b HHs5qXs0k28XyLC7FFwOkzX26hUp9l/SeXsDbKW5GTXnlJjj22YTuMW0RNPxB57IKNBF /KWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :mime-version:user-agent:date:message-id:autocrypt:subject:from:cc :to:dkim-signature; bh=s95ZqXbuHU1ft9LXvAawuXxVZSE5U4cxvAcYKpIWGKY=; b=hl8T1IRS7rHv0h5o9gRkCD6UiNgXEfJW6zFmvP0WB4s3eAKoUFrUeegWdekhTrqExW 1cPPT42qERvlXW9v4G65fPeqQH2OH1aMk7VpYBgj8cEqb/2/IgmshEpsSb7q6RtQbfza IfdyWHOJj0YKZPCMDw+Vm+n+pOfxD752wZAQGeqNeX6wFOl+sXMEwvO+52GLa8ZOFrhs 5cD9OiP3iAHMNgXtvMMGSLXw5rIHuk/qkj1nayL52Yuon6+fJhNroWs7CBZz2VwxtTA+ RryIjIQRKU877kImTY0e46qtKJN9qTAxLh5fO36L+b1cjxApd7hKzQbc5L6B/nGvD/ba VXPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@jan-o-sch.net header.s=mail header.b=AAg79erf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gb36si21679559ejc.696.2020.12.30.05.49.08; Wed, 30 Dec 2020 05:49:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@jan-o-sch.net header.s=mail header.b=AAg79erf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727091AbgL3NqX (ORCPT + 99 others); Wed, 30 Dec 2020 08:46:23 -0500 Received: from brockman.in8.de ([85.214.220.56]:35655 "EHLO mail.in8.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726954AbgL3NqW (ORCPT ); Wed, 30 Dec 2020 08:46:22 -0500 X-Greylist: delayed 520 seconds by postgrey-1.27 at vger.kernel.org; Wed, 30 Dec 2020 08:46:21 EST Received: from [192.168.2.125] (p5dfd40c8.dip0.t-ipconnect.de [93.253.64.200]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.in8.de (Postfix) with ESMTPSA id 45D646AC061; Wed, 30 Dec 2020 14:37:00 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=jan-o-sch.net; s=mail; t=1609335420; bh=mhW3nYdgmrUghD+cqjbyyYOsTEaazpNs35ojfAr/NIk=; h=To:Cc:From:Subject:Date:From; b=AAg79erf5TeqUHHIj8KRW3VqAQOouzpf1EDd6O3JFEys2L7Whac0feIgnV/NyhmIU FWJkZgSeodJlLUqjC6yVV8VyNZaEVPaniGJSP3FPOBvswXNVzYggA4NZgYzMUoXnYx IHDoB45Z6pxN443q+ONP5KtpggMMTkstS0ZRV1cy7FahnNH9uEpWvWxHTdOdqFYspU DfOysgF8pGxfs7qYy6NAIhED0mRzxb/zILz7vkiquLF5cNGr9/v4WyuRO/2RSw6Jrr 6fFtAcydhwQLiys0s1k892Nyn5IpYlFxihNeFLQKg5l4sevfAPezfZQiG+Ou8LVZRh CfxGNX9RVGUTg== To: Andy Whitcroft , Joe Perches Cc: linux-kernel@vger.kernel.org From: Jan Schlien Subject: [BUG] checkpatch: non-standard types cannot be declared after '}' Autocrypt: addr=list.lkml@jan-o-sch.net; prefer-encrypt=mutual; keydata= LS0tLS1CRUdJTiBQR1AgUFVCTElDIEtFWSBCTE9DSy0tLS0tClZlcnNpb246IEdudVBHIHYy CgptUUlOQkZpbTJ3QUJFQUM0V0c1WnA4Mnh1amV4UlduWGJ5TkhCWUpuaDFnelA4bWZKdy82 RGR1ZVZOWVZMK2s5ClpWeG5NSk8xd1pBREJjRDE0QXZkYTR4VXU4Q0g3VjRyRmJZbWRrS1pu VCt3MXY4WUtxWjJ0dDMyRWx3eGkwV2cKM0VhMWlWZXRvUnBsNS9tRy9VV2JiNjB5eGJFbURW a282anplaFFWTlo3a241UEFlYWxGdkI2cXpDcmdJS2FrUgo5L3FDZzU1UEl6bXROejVVek40 K1JWSGFOMmlEQW5ZY0w1cWk5T1hxNER6T3QrbHF5ZzkrNll0UEtnT1lNS3F4ClZiWmtRRTdD dzhWVHVHQUlNK2o2YzNiMGRyTWlRczRiTklRdkhLOC8vbUZQZHRGa2RPTnpsNXRKbFRiVjB4 RnEKcjg5WkVCN3BLZ25OOThoTllUOGttczdzNkVqaitqd04yS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2 Q2xKV3RuSC9hNjdIMkVKWDJkcGQ4L3Nnc3FhY1djUApxeG42c1UzTjdvU2h2Vk5zUU9XaHB3 ekV0dVVjeGMvdThpTnVUNEttY3pDOUZYTy9LYlpFRkZlMTN3THFrdEVvCmwxMlFUSUpoUmRE Y0FGaVFYK0ZxQkxGamV1dUI5ZjZVelU2MkQ2dkV5ekNCYlhodjlLMis5VDRYT2JnRTFicFYK b1M1eGtlcjdRei93TDkySmMybzZRdXYvUVlSSFVTQlBaaU5FY0lrZUFmNDI1TmFORFk1d3VP d3pRcEw1WmZPWApOb0VTTnpidG91aXFpTE42akkrT0RVVWZXR3lubHAvTnhEWmN5WkF3Mndo dURGYjNyY2xLNnBKaVpNSEcxNGI0CkswRUl2OXY2ejBkVm9TNFJIeXNMeXpmUlp2SkNxL24w TTFManI2dDVyRFk2VVk4T0pRVHpaODhJVnYwdEJGcHEKQW5Ta2xvMD0KPTBhMzAKLS0tLS1F TkQgUEdQIFBVQkxJQyBLRVkgQkxPQ0stLS0tLQo= Message-ID: Date: Wed, 30 Dec 2020 14:36:59 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, I found some odd behavior of checkpatch.pl, which I'm currently using for own projects outside the kernel, but I verified that kernel patches can be affected as well. Reproducer code (file test.c): ------------------>8-- void subfunc(void) { } FILE *g; int main(void) { return 0; } ------------------>8-- Checkpatch (called with extra options to only show the error to demonstrate here): -- $ diff -u /dev/null test.c | ./checkpatch.pl --no-tree --quiet --ignore MISSING_SIGN_OFF,SPDX_LICENSE_TAG,COMMIT_MESSAGE ERROR: need consistent spacing around '*' (ctx:WxV) #8: FILE: test.c:5: +FILE *g; ^ total: 1 errors, 0 warnings, 10 lines checked -- "Consistent spacing"? Checkpatch must be in the wrong mode here. When you add another declaration ("int a;") or even an empty statement (";") before the "FILE *g;" line the reported error vanishes. So patching $dbg_values = 2 in the code gives: -- 6 > . } 6 > EEEE 6 > ___ <_>WS( ) 7 > . 7 > EEE 7 > __ FILE *g; <_>WS( ) <_>IDENT(FILE) <_>WS( ) <_>OPV(*) <_>IDENT(g) <_>END(;) <_>WS( ) 8 > . FILE *g; 8 > EEVVVVVNVEE 8 > ______B___ -- I found the (not too recent) patch 3e469cdc08ac ("checkpatch: optimise statement scanner when mid-statement") and reverting it manually solves the issue. Also applying the following patch fixes the error for me: ------------------>8-- @@ -3913,7 +3913,7 @@ sub process { # it there is no point in retrying a statement scan # until we hit end of it. my $frag = $stat; $frag =~ s/;+\s*$//; - if ($frag !~ /(?:{|;)/) { + if ($frag !~ /(?:{|;|})/) { #print "skip<$line_nr_next>\n"; $suppress_statement = $line_nr_next; } ------------------>8-- The debug output changes to: -- 6 > . } 6 > EEEE 6 > ___ <_>WS( ) 7 > . 7 > EEE 7 > __ FILE *g; <_>WS( ) <_>DECLARE(FILE *) <_>IDENT(g) <_>END(;) <_>WS( ) 8 > . FILE *g; 8 > EETTTTTTVEE 8 > __________ -- Note "DECLARE(FILE *)" vs. "IDENT(FILE) WS( ) OPV(*)" before. The same behavior can be constructed after any closing brace. So any declaration of a non-standard type after a function, branch or loop will trigger the error. And there are quite a few non-standard types in the kernel tree as well. I am not sure about the optimization patch referred to earlier and if my suggested patch is correct with respect to it. If you think it is, feel free to commit it yourself or tell me to send a [PATCH]. Thanks, -Jan