The patch titled Subject: checkpatch: externalize the structs that should be const has been added to the -mm tree. Its filename is checkpatch-externalize-the-structs-that-should-be-const.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/checkpatch-externalize-the-structs-that-should-be-const.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/checkpatch-externalize-the-structs-that-should-be-const.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/SubmitChecklist when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Joe Perches <joe@xxxxxxxxxxx> Subject: checkpatch: externalize the structs that should be const Make it easier to add new structs that should be const. Link: http://lkml.kernel.org/r/e5a8da43e7c11525bafbda1ca69a8323614dd942.1472664220.git.joe@xxxxxxxxxxx Signed-off-by: Joe Perches <joe@xxxxxxxxxxx> Cc: Julia Lawall <julia.lawall@xxxxxxx> Cc: Kees Cook <keescook@xxxxxxxxxxxx> Cc: Andy Whitcroft <apw@xxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- scripts/checkpatch.pl | 64 ++++++++++------------------- scripts/const_structs.checkpatch | 39 +++++++++++++++++ 2 files changed, 63 insertions(+), 40 deletions(-) diff -puN scripts/checkpatch.pl~checkpatch-externalize-the-structs-that-should-be-const scripts/checkpatch.pl --- a/scripts/checkpatch.pl~checkpatch-externalize-the-structs-that-should-be-const +++ a/scripts/checkpatch.pl @@ -54,6 +54,7 @@ my $min_conf_desc_length = 4; my $spelling_file = "$D/spelling.txt"; my $codespell = 0; my $codespellfile = "/usr/share/codespell/dictionary.txt"; +my $conststructsfile = "$D/const_structs.checkpatch"; my $color = 1; my $allow_c99_comments = 1; @@ -624,6 +625,29 @@ if ($codespell) { $misspellings = join("|", sort keys %spelling_fix) if keys %spelling_fix; +my $const_structs = ""; +if (open(my $conststructs, '<', $conststructsfile)) { + while (<$conststructs>) { + my $line = $_; + + $line =~ s/\s*\n?$//g; + $line =~ s/^\s*//g; + + next if ($line =~ m/^\s*#/); + next if ($line =~ m/^\s*$/); + if ($line =~ /\s/) { + print("$conststructsfile: '$line' invalid - ignored\n"); + next; + } + + $const_structs .= '|' if ($const_structs ne ""); + $const_structs .= $line; + } + close($conststructsfile); +} else { + warn "No structs that should be const will be found - file '$conststructsfile': $!\n"; +} + sub build_types { my $mods = "(?x: \n" . join("|\n ", (@modifierList, @modifierListFile)) . "\n)"; my $all = "(?x: \n" . join("|\n ", (@typeList, @typeListFile)) . "\n)"; @@ -5912,46 +5936,6 @@ sub process { } # check for various structs that are normally const (ops, kgdb, device_tree) - my $const_structs = qr{ - acpi_dock_ops| - address_space_operations| - backlight_ops| - block_device_operations| - dentry_operations| - dev_pm_ops| - dma_map_ops| - extent_io_ops| - file_lock_operations| - file_operations| - hv_ops| - ide_dma_ops| - intel_dvo_dev_ops| - item_operations| - iwl_ops| - kgdb_arch| - kgdb_io| - kset_uevent_ops| - lock_manager_operations| - microcode_ops| - mtrr_ops| - neigh_ops| - nlmsvc_binding| - of_device_id| - pci_raw_ops| - pipe_buf_operations| - platform_hibernation_ops| - platform_suspend_ops| - proto_ops| - rpc_pipe_ops| - seq_operations| - snd_ac97_build_ops| - soc_pcmcia_socket_ops| - stacktrace_ops| - sysfs_ops| - tty_operations| - uart_ops| - usb_mon_operations| - wd_ops}x; if ($line !~ /\bconst\b/ && $line =~ /\bstruct\s+($const_structs)\b/) { WARN("CONST_STRUCT", diff -puN /dev/null scripts/const_structs.checkpatch --- /dev/null +++ a/scripts/const_structs.checkpatch @@ -0,0 +1,39 @@ +acpi_dock_ops +address_space_operations +backlight_ops +block_device_operations +dentry_operations +dev_pm_ops +dma_map_ops +extent_io_ops +file_lock_operations +file_operations +hv_ops +ide_dma_ops +intel_dvo_dev_ops +item_operations +iwl_ops +kgdb_arch +kgdb_io +kset_uevent_ops +lock_manager_operations +microcode_ops +mtrr_ops +neigh_ops +nlmsvc_binding +of_device_id +pci_raw_ops +pipe_buf_operations +platform_hibernation_ops +platform_suspend_ops +proto_ops +rpc_pipe_ops +seq_operations +snd_ac97_build_ops +soc_pcmcia_socket_ops +stacktrace_ops +sysfs_ops +tty_operations +uart_ops +usb_mon_operations +wd_ops _ Patches currently in -mm which might be from joe@xxxxxxxxxxx are wd719x-remove-last-declaration-using-define_pci_device_table.patch treewide-remove-references-to-the-now-unnecessary-define_pci_device_table.patch seq-proc-modify-seq_put_decimal_ll-to-take-a-const-char-not-char.patch meminfo-break-apart-a-very-long-seq_printf-with-ifdefs.patch spellingtxt-modeled-is-spelt-correctly.patch checkpatch-see-if-modified-files-are-marked-obsolete-in-maintainers.patch checkpatch-look-for-symbolic-permissions-and-suggest-octal-instead.patch checkpatch-test-multiple-line-block-comment-alignment.patch checkpatch-dont-test-for-prefer-ether_addr_foo.patch checkpatch-externalize-the-structs-that-should-be-const.patch const_structscheckpatch-add-frequently-used-from-julia-lawalls-list.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html