All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Mickaël Salaün" <mic@digikod.net>
To: Joe Perches <joe@perches.com>, Andy Whitcroft <apw@canonical.com>
Cc: Dwaipayan Ray <dwaipayanray1@gmail.com>,
	Lukas Bulwahn <lukas.bulwahn@gmail.com>,
	Shuah Khan <shuah@kernel.org>,
	linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
	Jerome Forissier <jerome.forissier@linaro.org>
Subject: Re: [RFC PATCH v1] checkpatch: Handle FILE pointer type
Date: Fri, 2 Sep 2022 13:04:04 +0200	[thread overview]
Message-ID: <b1cfb8d4-ad54-9cc1-3d9d-e690c81da016@digikod.net> (raw)
In-Reply-To: <026c08d9ab841ef626f80d968a532dea94a37c62.camel@perches.com>


On 02/09/2022 12:39, Joe Perches wrote:
> On Fri, 2022-09-02 at 11:04 +0200, Mickaël Salaün wrote:
>> On 01/09/2022 20:22, Joe Perches wrote:
>>> On Thu, 2022-09-01 at 11:49 -0400, Joe Perches wrote:
>>>> On Thu, 2022-09-01 at 16:59 +0200, Mickaël Salaün wrote:
>>>>> When using a "FILE *" type, checkpatch considers this an error.  Fix
>>>>> this by explicitly defining "FILE" as a common type.
>>>> []
>>>>> Another error may be throw when we use FIXTURE_{DATA,VARIANT}() structs,
>>>>> as defined in kselftest_harness.h .
>>>> []
>>>>> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
>>>> []
>>>>> @@ -576,10 +576,17 @@ our $typeKernelTypedefs = qr{(?x:
>>>>>    	(?:__)?(?:u|s|be|le)(?:8|16|32|64)|
>>>>>    	atomic_t
>>>>>    )};
>>>>> +our $typeStdioTypedefs = qr{(?x:
>>>>> +	FILE
>>>>> +)};
>>>>
>>>> I'm fine with this.
>>>>
>>>>> +# our $typeKselftestHarnessTypedefs = qr{(?x:
>>>>> +# 	FIXTURE_(?:DATA|VARIANT)\($Ident\)
>>>>> +# )};
>>>>
>>>> But not this.  Random userspace typedefs should likely
>>>> be kept in some local version of checkpatch.
>>>>
>>>> Or maybe add a command line option like --additional_typedefs=<file>.
>>>
>>> Oops.  I forgot it already exists:
>>>
>>>     --typedefsfile             Read additional types from this file
>>>
>>> commit 75ad8c575a5ad105e2afc2051c68abceb9c65431
>>> Author: Jerome Forissier <jerome.forissier@linaro.org>
>>> Date:   Mon May 8 15:56:00 2017 -0700
>>>
>>>       checkpatch: add --typedefsfile
>>>       
>>>       When using checkpatch on out-of-tree code, it may occur that some
>>>       project-specific types are used, which will cause spurious warnings.
>>>       Add the --typedefsfile option as a way to extend the known types and
>>>       deal with this issue.
>>
>> This doesn't work for the FIXTURE_DATA() case.
> 
> checkpatch is a stupid little script.
> It's not a c preprocessor nor a syntax complete compiler.
> It's really easy for macros to make its output invalid.
> If you feed obfuscated c to checkpatch, it'd be confused.
> (Same is true for tools like coccinelle btw, though cocci is far better)
> checkpatch will never be comprehensive nor perfect.
> It's expected its users will use their common sense about its
> output message validity.
> 
>> And I'm not sure how
>> contributors would know that they need to use this option with a
>> specific file.
> 
> --help exists
> 
> Maybe Documentation/dev-tools/checkpatch.rst could be expanded for
> --verbose mode.

I was thinking about which file to use, but I understand your point. 
I'll send a v2 with only the "FILE" addition.
FIXTURE_{DATA,VARIANT}() will just not be handled but that's OK.

      reply	other threads:[~2022-09-02 11:04 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-01 14:59 [RFC PATCH v1] checkpatch: Handle FILE pointer type Mickaël Salaün
2022-09-01 15:49 ` Joe Perches
2022-09-01 15:53   ` Mickaël Salaün
2022-09-01 18:22   ` Joe Perches
2022-09-02  9:04     ` Mickaël Salaün
2022-09-02 10:39       ` Joe Perches
2022-09-02 11:04         ` Mickaël Salaün [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b1cfb8d4-ad54-9cc1-3d9d-e690c81da016@digikod.net \
    --to=mic@digikod.net \
    --cc=apw@canonical.com \
    --cc=dwaipayanray1@gmail.com \
    --cc=jerome.forissier@linaro.org \
    --cc=joe@perches.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=lukas.bulwahn@gmail.com \
    --cc=shuah@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.