All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Weil <sw@weilnetz.de>
To: Peter Maydell <peter.maydell@linaro.org>,
	Markus Armbruster <armbru@redhat.com>
Cc: Alexey Kardashevskiy <aik@ozlabs.ru>,
	Blue Swirl <blauwirbel@gmail.com>,
	Don Slutz <Don@cloudswitch.com>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] checkpatch.pl question
Date: Sat, 07 Jun 2014 18:00:45 +0200	[thread overview]
Message-ID: <5393372D.7080501@weilnetz.de> (raw)
In-Reply-To: <CAFEAcA8Gb_QT9ZQ+Uk6=VF85C8vd9J0bhzLYJt589=GUwqTUxw@mail.gmail.com>

Am 07.06.2014 16:58, schrieb Peter Maydell:
> On 6 June 2014 08:17, Markus Armbruster <armbru@redhat.com> wrote:
>> --debug values=1 produces
>>
>> 188 > . extern int vfio_container_ioctl(AddressSpace *as, int32_t groupid,
>> 188 > EEVVVVVVVTTTTVVVVVVVVVVVVVVVVVVVVNTTTTTTTTTTTTTTVVCCTTTTTTTTVVVVVVVCC
>>
>> which suggests it recognizes the declaration just fine.
>>
>> Copying a few possible victims^Wexperts.
> 
> It's clearly something to do with it getting confused by the type name,
> because you can suppress the warning by just changing it so it has
> an "_t" suffix, for instance. In particular notice that the set of allowed
> type names constructed by the build_types() subroutine is extremely
> limited: it looks to me as if the script makes assumptions based on
> kernel style (where 'struct foo' is preferred over a typedef and plain
> 'foo') that allow it to assume that if it's not one of a very few allowed
> formats then it's not a type name.
> 
> I find this script extremely hard to understand, though.
> 
> thanks
> -- PMM
> 

Yes, but that's only part of the story. checkpatch.pl contains some
special handling for the standard C data types and also knows some Linux
data type patterns. It also handles the above case correctly in most
circumstances because there is special code for "*" used in function
argument lists.

Here checkpatch.pl gets confused by a totally different line of the patch:

 type_init(register_vfio_pci_dev_type)

Simply adding a semicolon at the end of that line would help, but is of
course not correct (note that there is already some QEMU code which adds
such a semicolon and which should be fixed). It's generally very
difficult or even impossible for code analysers with a limited view to
analyse macro calls correctly. A human reviewer has the same problem.

checkpatch.pl could be improved to handle the patch correctly: the
type_init line and the line which raises the error message belong to
different files. Obviously some global state variables are not reset
when checkpatch.pl detects patch code belonging to a new file. I'm still
searching which ones. A similar problem might also occur when more than
one patch is checked: this also does not reset all relevant variables
when switching from one patch file to the next one. The original Linux
version of checkpatch.pl shows the same bug.

Regards
Stefan

PS. I just sent a first patch for checkpatch.pl which is totally
unrelated to the above problem, but which I noticed while I investigated it.

  reply	other threads:[~2014-06-07 16:01 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-06  3:37 [Qemu-devel] checkpatch.pl question Alexey Kardashevskiy
2014-06-06  6:27 ` Markus Armbruster
2014-06-06  6:33   ` Alexey Kardashevskiy
2014-06-06  7:17     ` Markus Armbruster
2014-06-07 14:58       ` Peter Maydell
2014-06-07 16:00         ` Stefan Weil [this message]
2014-06-07 16:27           ` Peter Maydell
2014-06-08  8:32             ` Paolo Bonzini

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=5393372D.7080501@weilnetz.de \
    --to=sw@weilnetz.de \
    --cc=Don@cloudswitch.com \
    --cc=aik@ozlabs.ru \
    --cc=armbru@redhat.com \
    --cc=blauwirbel@gmail.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.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.