[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 01/22] scripts/checkpatch.pl: Enforce multiline comme
From: |
Peter Maydell |
Subject: |
[Qemu-devel] [PULL 01/22] scripts/checkpatch.pl: Enforce multiline comment syntax |
Date: |
Fri, 14 Dec 2018 14:41:53 +0000 |
We now require Linux-kernel-style multiline comments:
/*
* line one
* line two
*/
Enforce this in checkpatch.pl, by backporting the relevant
parts of the Linux kernel's checkpatch.pl. (The only changes
needed are that Linux's checkpatch.pl WARN() function takes
an extra argument that ours does not, and the kernel has a
special case for networking code we don't want.)"
The kernel's checkpatch does not enforce "leading /* on
a line of its own, so that part is unique to QEMU's checkpatch.
Sample warning output:
WARNING: Block comments use a leading /* on a separate line
#34: FILE: hw/intc/arm_gicv3_common.c:39:
+ /* Older versions of QEMU had a bug in the handling of state save/restore
Signed-off-by: Peter Maydell <address@hidden>
Acked-by: Thomas Huth <address@hidden>
Reviewed-by: Markus Armbruster <address@hidden>
---
scripts/checkpatch.pl | 48 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 48 insertions(+)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index a892a6cc7c3..18e16b79dfc 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -1569,6 +1569,54 @@ sub process {
# check we are in a valid C source file if not then ignore this hunk
next if ($realfile !~ /\.(h|c|cpp)$/);
+# Block comment styles
+
+ # Block comments use /* on a line of its own
+ if ($rawline !~ address@hidden/\*.*\*/[ \t]*$@ && #inline
/*...*/
+ $rawline =~ address@hidden/\*\*?[ \t]*.+[ \t]*$@) { # /* or
/** non-blank
+ WARN("Block comments use a leading /* on a separate
line\n" . $herecurr);
+ }
+
+# Block comments use * on subsequent lines
+ if ($prevline =~ /$;[ \t]*$/ && #ends in comment
+ $prevrawline =~ /^\+.*?\/\*/ && #starting /*
+ $prevrawline !~ /\*\/[ \t]*$/ && #no trailing */
+ $rawline =~ /^\+/ && #line is new
+ $rawline !~ /^\+[ \t]*\*/) { #no leading *
+ WARN("Block comments use * on subsequent lines\n" .
$hereprev);
+ }
+
+# Block comments use */ on trailing lines
+ if ($rawline !~ address@hidden \t]*\*/[ \t]*$@ &&
#trailing */
+ $rawline !~ address@hidden/\*.*\*/[ \t]*$@ && #inline
/*...*/
+ $rawline !~ address@hidden,}/[ \t]*$@ && #trailing **/
+ $rawline =~ address@hidden \t]*.+\*\/[ \t]*$@) { #non
blank */
+ WARN("Block comments use a trailing */ on a separate
line\n" . $herecurr);
+ }
+
+# Block comment * alignment
+ if ($prevline =~ /$;[ \t]*$/ && #ends in comment
+ $line =~ /^\+[ \t]*$;/ && #leading comment
+ $rawline =~ /^\+[ \t]*\*/ && #leading *
+ (($prevrawline =~ /^\+.*?\/\*/ && #leading /*
+ $prevrawline !~ /\*\/[ \t]*$/) || #no trailing */
+ $prevrawline =~ /^\+[ \t]*\*/)) { #leading *
+ my $oldindent;
+ $prevrawline =~ address@hidden([ \t]*/?)\*@;
+ if (defined($1)) {
+ $oldindent = expand_tabs($1);
+ } else {
+ $prevrawline =~ address@hidden(.*/?)\*@;
+ $oldindent = expand_tabs($1);
+ }
+ $rawline =~ address@hidden([ \t]*)\*@;
+ my $newindent = $1;
+ $newindent = expand_tabs($newindent);
+ if (length($oldindent) ne length($newindent)) {
+ WARN("Block comments should align the * on each
line\n" . $hereprev);
+ }
+ }
+
# Check for potential 'bare' types
my ($stat, $cond, $line_nr_next, $remain_next, $off_next,
$realline_next);
--
2.19.2
- [Qemu-devel] [PULL 00/22] misc queue, Peter Maydell, 2018/12/14
- [Qemu-devel] [PULL 02/22] exec.c: Rename cpu_physical_memory_write_rom_internal(), Peter Maydell, 2018/12/14
- [Qemu-devel] [PULL 01/22] scripts/checkpatch.pl: Enforce multiline comment syntax,
Peter Maydell <=
- [Qemu-devel] [PULL 04/22] disas.c: Use address_space_read() to read memory, Peter Maydell, 2018/12/14
- [Qemu-devel] [PULL 05/22] monitor: Use address_space_read() to read memory, Peter Maydell, 2018/12/14
- [Qemu-devel] [PULL 06/22] elf_ops.h: Use address_space_write() to write memory, Peter Maydell, 2018/12/14
- [Qemu-devel] [PULL 03/22] Rename cpu_physical_memory_write_rom() to address_space_write_rom(), Peter Maydell, 2018/12/14
- [Qemu-devel] [PULL 07/22] hw/ppc/mac_newworld, mac_oldworld: Don't use load_image(), Peter Maydell, 2018/12/14
- [Qemu-devel] [PULL 09/22] hw/smbios/smbios.c: Don't use load_image(), Peter Maydell, 2018/12/14
- [Qemu-devel] [PULL 08/22] hw/ppc/ppc405_boards: Don't use load_image(), Peter Maydell, 2018/12/14
- [Qemu-devel] [PULL 11/22] hw/i386/pc.c: Don't use load_image(), Peter Maydell, 2018/12/14
- [Qemu-devel] [PULL 10/22] hw/pci/pci.c: Don't use load_image(), Peter Maydell, 2018/12/14
- [Qemu-devel] [PULL 12/22] hw/i386/multiboot.c: Don't use load_image(), Peter Maydell, 2018/12/14