Commit Graph

123 Commits

Author SHA1 Message Date
Fam Zheng 04f2562f8e checkpatch: Escape left braces in regex
Latest perl now deprecates "{" literal in regex and print warnings like
"unescaped left brace in regex is deprecated".  Add escape to keep it
happy.

Signed-off-by: Fam Zheng <famz@redhat.com>
Message-Id: <1441969656-2640-1-git-send-email-famz@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2015-09-16 17:33:33 +02:00
Paolo Bonzini f1e155bbf8 checkpatch: remove tests that are not relevant outside the kernel
Fully removing Sparse support requires more invasive changes.  Only
remove the really kernel-specific parts such as address space names.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2015-09-09 15:34:55 +02:00
Paolo Bonzini 71c47b01ca checkpatch: adapt some tests to QEMU
Mostly change severity levels, but some tests can also be adjusted to refer
to QEMU APIs or data structures.

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2015-09-09 15:34:55 +02:00
Stefan Hajnoczi 8b6ee9aeb3 checkpatch: complain about ffs(3) calls
The ffs(3) family of functions is not portable.  MinGW doesn't always
provide the function.

Use ctz32() or ctz64() instead.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-id: 1427124571-28598-10-git-send-email-stefanha@redhat.com
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2015-04-28 15:36:08 +02:00
Max Reitz a97ceca578 checkpatch: Brace handling on multi-line condition
CODING_STYLE states the following about braces around blocks:

> The opening brace is on the line that contains the control flow
> statement that introduces the new block; [...]

This is obviously impossible with multi-line conditions. Therefore,
CODING_STYLE does not make any clear statement about where to put the
opening brace after a multi-line condition.

There is a reason to prefer to place the opening brace on an own line
after such a condition while still placing it on the same line as the
"control flow statement" if possible; that reason is that the last line
of a multi-line condition is indented, in the case of "if", it is often
indented by four spaces, just as much as the first statement in the
block will be indented. This is hard to read as there is no clearly
visible distinction between condition and block. Placing the opening
brace on a separate line solves this issue.

Also, there are cases where placing the opening brace on a separate line
is the only viable option; if the previous line had nearly 80 characters
and splitting it is not desirable, the opening brace is naturally placed
on an own line.

This patch fixes checkpatch.pl to not complain about braces on own lines
if the condition introducing the block spanned more than one line, or if
the previous line had 79 or 80 characters.

Furthermore, the warning about not having braces around a block is fixed
to mind braces not being on the last line of the condition.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2015-01-13 11:47:56 +00:00
Paolo Bonzini a6859deb69 checkpatch.pl: adjust typedef definition to QEMU coding style
Most QEMU typedefs are camelcase, starting with one uppercase letter
and containing at least one lowercase letter.  There are a few
all-uppercase types, add the most common too.

This fixes recognition of types in lines such as

    static __attribute__((unused)) inline void tcg_out8(TCGContext *s, uint8_t v)

(Example provided by Peter Maydell).

Reported-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Cc: Peter Maydell <peter.maydell@linaro.org>
Cc: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2014-08-26 13:44:28 +02:00
Tomoki Sekiyama 69d5d21f90 checkpatch.pl: Check .cpp files
Enable checkpatch.pl to apply the same checks as C source files for
C++ files with .cpp extensions. It also adds some exceptions for C++
sources to suppress errors for:
  - <> used in C++ template arguments (e.g. template <class T>)
  - :: used to represent namespaces   (e.g. SomeClass::method())
  - : used in class declaration       (e.g. class T : public Super)
  - ~ used in destructor method name  (e.g. T::~T())
  - spacing around 'catch'            (e.g. catch (...))

Signed-off-by: Tomoki Sekiyama <tomoki.sekiyama@hds.com>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
2013-09-09 14:17:56 -05:00
Don Slutz dfe7053a34 CHECKPATCH: Add warning for single else statement.
For an example:

WARNING: braces {} are necessary even for single statement blocks
+    } else
+        return env->regs[R_EAX];

total: 0 errors, 1 warnings, 41 lines checked
Signed-off-by: Don Slutz <Don@CloudSwitch.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2012-09-05 19:17:49 +00:00
Don Slutz 69402a6944 CHECKPATCH: Add --debug adv_apw
Add debug options to find this issue.  They were not listed
in the help because the are not simple to understand the output of.

Signed-off-by: Don Slutz <Don@CloudSwitch.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2012-09-05 19:17:49 +00:00
Don Slutz 5424302e56 CHECKPATCH: Add --debug adv_checking
Add debug options to find this issue.  They were not listed
in the help because the are not simple to understand the output of.

Signed-off-by: Don Slutz <Don@CloudSwitch.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2012-09-05 19:17:49 +00:00
Don Slutz a99ac041e9 CHECKPATCH: Add --debug adv_dcs
Add debug options to find this issue.  They were not listed
in the help because the are not simple to understand the output of.

Signed-off-by: Don Slutz <Don@CloudSwitch.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2012-09-05 19:17:49 +00:00
Stefan Weil 9964d8f942 checkpatch: Add QEMU specific rule
The new rule detects two wrong variants of QEMU.
It was tested with commit b5a8fe5e.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2012-06-22 09:41:31 +01:00
Stefan Weil e7d81004e4 Fix spelling in comments, documentation and messages
accidently->accidentally
annother->another
choosen->chosen
consideres->considers
decriptor->descriptor
developement->development
paramter->parameter
preceed->precede
preceeding->preceding
priviledge->privilege
propogation->propagation
substraction->subtraction
throught->through
upto->up to
usefull->useful

Fix also grammar in posix-aio-compat.c

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2011-12-14 11:09:44 +00:00
Dong Xu Wang 68dfbcd4d5 fix spelling in scripts sub directory
Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2011-12-02 10:50:57 +00:00
Florian Mickler 61669f9a83 checkpatch.pl: fix CAST detection
We should only claim that something is a cast if we did not encouter a
token before, that did set av_pending.

This fixes the operator * in the line below to be detected as binary (vs
unary).

kmalloc(sizeof(struct alphatrack_ocmd) * true_size, GFP_KERNEL);

Reported-by: Peter Chubb <nicta.com.au>
Signed-off-by: Florian Mickler <florian@mickler.org>
(cherry-picked from Linux kernel commit c023e4734c3e8801e0ecb5e81b831d42a374d861)
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Cc: Blue Swirl <blauwirbel@gmail.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-11-26 09:47:00 +00:00
Paolo Bonzini e589728b6f checkpatch: remove rule on non-indented labels
There are 508 non-indented (non-default) labels, and 511 that are
indented.  So the rule is debatable at least.  Actually, in the
common case of labels at the outermost scope, there is really just
one place where to put the label, so the rule is just wrong IMHO.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-11-01 16:52:05 -05:00
Pavel Borzenkov 01c4330b58 checkpatch: fix braces {} handling
checkpatch.pl doesn't report warning for if/else statements with missing
'else' braces:

if (something) {
    foo;
} else
    bar;

The patch has been tested using the last 100 commits.

Signed-off-by: Pavel Borzenkov <pavel.borzenkov@gmail.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-08-27 15:44:16 +00:00
Blue Swirl d0510af26d checkpatch: Fix bracing false positives on #if
789f88d0b2 only fixed #else,
fix also #if.

Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-07-20 21:07:24 +00:00
Alexander Graf 9fbe478444 checkpatch: don't error out on },{ lines
When having code like this:

    static PCIDeviceInfo piix_ide_info[] = {
        {
            .qdev.name    = "piix3-ide",
            .qdev.size    = sizeof(PCIIDEState),
            .qdev.no_user = 1,
            .no_hotplug   = 1,
            .init         = pci_piix_ide_initfn,
            .vendor_id    = PCI_VENDOR_ID_INTEL,
            .device_id    = PCI_DEVICE_ID_INTEL_82371SB_1,
            .class_id     = PCI_CLASS_STORAGE_IDE,
        },{
            .qdev.name    = "piix4-ide",
            .qdev.size    = sizeof(PCIIDEState),
            .qdev.no_user = 1,
            .no_hotplug   = 1,
            .init         = pci_piix_ide_initfn,
            .vendor_id    = PCI_VENDOR_ID_INTEL,
            .device_id    = PCI_DEVICE_ID_INTEL_82371AB,
            .class_id     = PCI_CLASS_STORAGE_IDE,
        },{
            /* end of list */
        }
    };

checkpatch currently errors out, claiming that spaces need to follow
commas. However, this particular style of defining structs is pretty
common in qemu code and very readable. So let's declare it as supported
for the above case.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
2011-07-17 01:54:25 +02:00
Blue Swirl ad36ce8ba9 checkpatch.pl: don't complain about old lines with tabs
Don't complain when the patch includes lines with tabs
only in the hunk's untouched context.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-02-05 13:18:20 +00:00
Jan Kiszka 789f88d0b2 checkpatch: Fix bracing false positives on #else
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-01-21 17:32:45 +00:00
Blue Swirl b646968336 checkpatch: adjust to QEMUisms
Change checkpatch.pl for QEMU use:
 - Root directory detection
 - Forbid tabs
 - Indent at 4 spaces
 - Allow typedefs
 - Enforce brace use even for single statement blocks
 - Don't suggest nonexistent cleanup tools

Mention the script in CODING_STYLE.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-01-20 20:58:56 +00:00
Blue Swirl 1ec3f6f9ab Add checkpatch.pl from Linux kernel
Unchanged import from
http://www.kernel.org/pub/linux/kernel/people/apw/checkpatch/checkpatch.pl-0.31

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-01-20 20:54:26 +00:00