From 0f684317a7e0e7b6075ebfa5311b0c106eb1b802 Mon Sep 17 00:00:00 2001 From: Michael Ellerman Date: Tue, 3 Nov 2015 21:39:52 +1100 Subject: scripts/tags.sh: Teach tags about more powerpc macros Teach tags.sh about the powerpc PCI macros, eg. readl/writel etc. Signed-off-by: Michael Ellerman Signed-off-by: Michal Marek --- scripts/tags.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/tags.sh b/scripts/tags.sh index 262889046703..f69fa0c87312 100755 --- a/scripts/tags.sh +++ b/scripts/tags.sh @@ -200,6 +200,7 @@ exuberant() --regex-c++='/TASK_PFA_CLEAR\([^,]*,\s*([^)]*)\)/task_clear_\1/'\ --regex-c++='/DEF_MMIO_(IN|OUT)_(X|D)\(([^,]*),\s*[^)]*\)/\3/' \ --regex-c++='/DEBUGGER_BOILERPLATE\(([^,]*)\)/\1/' \ + --regex-c++='/DEF_PCI_AC_(NO)?RET\(([^,]*),.*/\2/' \ --regex-c='/PCI_OP_READ\((\w*).*[1-4]\)/pci_bus_read_config_\1/' \ --regex-c='/PCI_OP_WRITE\((\w*).*[1-4]\)/pci_bus_write_config_\1/' \ --regex-c='/DEFINE_(MUTEX|SEMAPHORE|SPINLOCK)\((\w*)/\2/v/' \ -- cgit v1.2.3 From 4b63f603135022ca048524cd16f1c6a76a3f169d Mon Sep 17 00:00:00 2001 From: Riku Voipio Date: Tue, 1 Sep 2015 17:14:21 +0300 Subject: package Makefile: fix perf-tar targets when outdir is set building with $srctree != $objtree, perf-tar-* targets fail to read the MANIFEST file and add the PERF-VERSION-FILE needed by out-of-tree builds. The build errors and an incorrect tar is created: $ make O=build-x86 perf-targz-src-pkg TAR cat: ../tools/perf/MANIFEST: No such file or directory tar: perf-4.1.0-rc8/PERF-VERSION-FILE: Cannot stat: No such file or dir.. tar: Exiting with failure status due to previous errors Kbuild sets objtree to "." and srctree to ".." The command to output MANIFEST becomes: $(cd ..; echo $(cat ../tools/perf/MANIFEST)) Without MANIFEST, the entire kernel source tree is added to the perf source tarball. The *correct* fix is to keep the cd and remove srctree from cat command line since MANIFEST has wildcards that fail to expand working directory isn't srctree. Second, PERF-VERSION-FILE gets not added, because in-tree build path is hardcoded to Makefile: util/PERF-VERSION-GEN ../../$(perf-tar)/ 2>/dev/null) The PERF-VERSION-GEN needs to be run from tools/perf directory, and the output directory needs to be changed from relative to to absolute. This can be achieved using the $(CURDIR) variable. Also remove the error redirect to /dev/null which hid the error. Signed-off-by: Riku Voipio Signed-off-by: Michal Marek --- scripts/package/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/package/Makefile b/scripts/package/Makefile index 1aca224e8597..c2c7389bfbab 100644 --- a/scripts/package/Makefile +++ b/scripts/package/Makefile @@ -118,12 +118,12 @@ quiet_cmd_perf_tar = TAR cmd_perf_tar = \ git --git-dir=$(srctree)/.git archive --prefix=$(perf-tar)/ \ HEAD^{tree} $$(cd $(srctree); \ - echo $$(cat $(srctree)/tools/perf/MANIFEST)) \ + echo $$(cat tools/perf/MANIFEST)) \ -o $(perf-tar).tar; \ mkdir -p $(perf-tar); \ git --git-dir=$(srctree)/.git rev-parse HEAD > $(perf-tar)/HEAD; \ (cd $(srctree)/tools/perf; \ -util/PERF-VERSION-GEN ../../$(perf-tar)/ 2>/dev/null); \ +util/PERF-VERSION-GEN $(CURDIR)/$(perf-tar)/); \ tar rf $(perf-tar).tar $(perf-tar)/HEAD $(perf-tar)/PERF-VERSION-FILE; \ rm -r $(perf-tar); \ $(if $(findstring tar-src,$@),, \ -- cgit v1.2.3 From d2fb5aeda926307e4d95e3e824146aee9943de59 Mon Sep 17 00:00:00 2001 From: Michal Marek Date: Wed, 14 Oct 2015 09:45:52 +0200 Subject: tags: Treat header files as C code This allows to apply the same patters to both source and header files. The effect is mostly visible in the case of DECLARE_BITMAP, but there are small gains all over the place. There is also lots of random changes in the diff, I believe this is simply because there are still lots of unexpanded macros in the code and the C and C++ parsers fail and recover at different points. Also, qconf.h is parsed as C, but that's a negligible regression. Signed-off-by: Michal Marek --- scripts/tags.sh | 66 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/scripts/tags.sh b/scripts/tags.sh index f69fa0c87312..25e30c30d1ad 100755 --- a/scripts/tags.sh +++ b/scripts/tags.sh @@ -165,42 +165,42 @@ exuberant() -I EXPORT_SYMBOL,EXPORT_SYMBOL_GPL,ACPI_EXPORT_SYMBOL \ -I DEFINE_TRACE,EXPORT_TRACEPOINT_SYMBOL,EXPORT_TRACEPOINT_SYMBOL_GPL \ -I static,const \ - --extra=+f --c-kinds=+px \ + --extra=+f --c-kinds=+px --langmap=c:+.h \ --regex-asm='/^(ENTRY|_GLOBAL)\(([^)]*)\).*/\2/' \ --regex-c='/^SYSCALL_DEFINE[[:digit:]]?\(([^,)]*).*/sys_\1/' \ --regex-c='/^COMPAT_SYSCALL_DEFINE[[:digit:]]?\(([^,)]*).*/compat_sys_\1/' \ - --regex-c++='/^TRACE_EVENT\(([^,)]*).*/trace_\1/' \ - --regex-c++='/^TRACE_EVENT\(([^,)]*).*/trace_\1_rcuidle/' \ - --regex-c++='/^DEFINE_EVENT\([^,)]*, *([^,)]*).*/trace_\1/' \ - --regex-c++='/^DEFINE_EVENT\([^,)]*, *([^,)]*).*/trace_\1_rcuidle/' \ - --regex-c++='/PAGEFLAG\(([^,)]*).*/Page\1/' \ - --regex-c++='/PAGEFLAG\(([^,)]*).*/SetPage\1/' \ - --regex-c++='/PAGEFLAG\(([^,)]*).*/ClearPage\1/' \ - --regex-c++='/TESTSETFLAG\(([^,)]*).*/TestSetPage\1/' \ - --regex-c++='/TESTPAGEFLAG\(([^,)]*).*/Page\1/' \ - --regex-c++='/SETPAGEFLAG\(([^,)]*).*/SetPage\1/' \ - --regex-c++='/__SETPAGEFLAG\(([^,)]*).*/__SetPage\1/' \ - --regex-c++='/TESTCLEARFLAG\(([^,)]*).*/TestClearPage\1/' \ - --regex-c++='/__TESTCLEARFLAG\(([^,)]*).*/TestClearPage\1/' \ - --regex-c++='/CLEARPAGEFLAG\(([^,)]*).*/ClearPage\1/' \ - --regex-c++='/__CLEARPAGEFLAG\(([^,)]*).*/__ClearPage\1/' \ - --regex-c++='/__PAGEFLAG\(([^,)]*).*/__SetPage\1/' \ - --regex-c++='/__PAGEFLAG\(([^,)]*).*/__ClearPage\1/' \ - --regex-c++='/PAGEFLAG_FALSE\(([^,)]*).*/Page\1/' \ - --regex-c++='/TESTSCFLAG\(([^,)]*).*/TestSetPage\1/' \ - --regex-c++='/TESTSCFLAG\(([^,)]*).*/TestClearPage\1/' \ - --regex-c++='/SETPAGEFLAG_NOOP\(([^,)]*).*/SetPage\1/' \ - --regex-c++='/CLEARPAGEFLAG_NOOP\(([^,)]*).*/ClearPage\1/' \ - --regex-c++='/__CLEARPAGEFLAG_NOOP\(([^,)]*).*/__ClearPage\1/' \ - --regex-c++='/TESTCLEARFLAG_FALSE\(([^,)]*).*/TestClearPage\1/' \ - --regex-c++='/__TESTCLEARFLAG_FALSE\(([^,)]*).*/__TestClearPage\1/' \ - --regex-c++='/_PE\(([^,)]*).*/PEVENT_ERRNO__\1/' \ - --regex-c++='/TASK_PFA_TEST\([^,]*,\s*([^)]*)\)/task_\1/' \ - --regex-c++='/TASK_PFA_SET\([^,]*,\s*([^)]*)\)/task_set_\1/' \ - --regex-c++='/TASK_PFA_CLEAR\([^,]*,\s*([^)]*)\)/task_clear_\1/'\ - --regex-c++='/DEF_MMIO_(IN|OUT)_(X|D)\(([^,]*),\s*[^)]*\)/\3/' \ - --regex-c++='/DEBUGGER_BOILERPLATE\(([^,]*)\)/\1/' \ - --regex-c++='/DEF_PCI_AC_(NO)?RET\(([^,]*),.*/\2/' \ + --regex-c='/^TRACE_EVENT\(([^,)]*).*/trace_\1/' \ + --regex-c='/^TRACE_EVENT\(([^,)]*).*/trace_\1_rcuidle/' \ + --regex-c='/^DEFINE_EVENT\([^,)]*, *([^,)]*).*/trace_\1/' \ + --regex-c='/^DEFINE_EVENT\([^,)]*, *([^,)]*).*/trace_\1_rcuidle/' \ + --regex-c='/PAGEFLAG\(([^,)]*).*/Page\1/' \ + --regex-c='/PAGEFLAG\(([^,)]*).*/SetPage\1/' \ + --regex-c='/PAGEFLAG\(([^,)]*).*/ClearPage\1/' \ + --regex-c='/TESTSETFLAG\(([^,)]*).*/TestSetPage\1/' \ + --regex-c='/TESTPAGEFLAG\(([^,)]*).*/Page\1/' \ + --regex-c='/SETPAGEFLAG\(([^,)]*).*/SetPage\1/' \ + --regex-c='/__SETPAGEFLAG\(([^,)]*).*/__SetPage\1/' \ + --regex-c='/TESTCLEARFLAG\(([^,)]*).*/TestClearPage\1/' \ + --regex-c='/__TESTCLEARFLAG\(([^,)]*).*/TestClearPage\1/' \ + --regex-c='/CLEARPAGEFLAG\(([^,)]*).*/ClearPage\1/' \ + --regex-c='/__CLEARPAGEFLAG\(([^,)]*).*/__ClearPage\1/' \ + --regex-c='/__PAGEFLAG\(([^,)]*).*/__SetPage\1/' \ + --regex-c='/__PAGEFLAG\(([^,)]*).*/__ClearPage\1/' \ + --regex-c='/PAGEFLAG_FALSE\(([^,)]*).*/Page\1/' \ + --regex-c='/TESTSCFLAG\(([^,)]*).*/TestSetPage\1/' \ + --regex-c='/TESTSCFLAG\(([^,)]*).*/TestClearPage\1/' \ + --regex-c='/SETPAGEFLAG_NOOP\(([^,)]*).*/SetPage\1/' \ + --regex-c='/CLEARPAGEFLAG_NOOP\(([^,)]*).*/ClearPage\1/' \ + --regex-c='/__CLEARPAGEFLAG_NOOP\(([^,)]*).*/__ClearPage\1/' \ + --regex-c='/TESTCLEARFLAG_FALSE\(([^,)]*).*/TestClearPage\1/' \ + --regex-c='/__TESTCLEARFLAG_FALSE\(([^,)]*).*/__TestClearPage\1/' \ + --regex-c='/_PE\(([^,)]*).*/PEVENT_ERRNO__\1/' \ + --regex-c='/TASK_PFA_TEST\([^,]*,\s*([^)]*)\)/task_\1/' \ + --regex-c='/TASK_PFA_SET\([^,]*,\s*([^)]*)\)/task_set_\1/' \ + --regex-c='/TASK_PFA_CLEAR\([^,]*,\s*([^)]*)\)/task_clear_\1/'\ + --regex-c='/DEF_MMIO_(IN|OUT)_(X|D)\(([^,]*),\s*[^)]*\)/\3/' \ + --regex-c='/DEBUGGER_BOILERPLATE\(([^,]*)\)/\1/' \ + --regex-c='/DEF_PCI_AC_(NO)?RET\(([^,]*),.*/\2/' \ --regex-c='/PCI_OP_READ\((\w*).*[1-4]\)/pci_bus_read_config_\1/' \ --regex-c='/PCI_OP_WRITE\((\w*).*[1-4]\)/pci_bus_write_config_\1/' \ --regex-c='/DEFINE_(MUTEX|SEMAPHORE|SPINLOCK)\((\w*)/\2/v/' \ -- cgit v1.2.3 From e594a178123eb77a3238a73ca35fabc98dec3599 Mon Sep 17 00:00:00 2001 From: Michal Marek Date: Wed, 14 Oct 2015 10:35:23 +0200 Subject: aic7xxx: Avoid name collision with Rename the local definition of LIST_HEAD to BSD_LIST_HEAD. This fixes a ctags error if we apply the C rules to header files as well: ctags: Warning: drivers/scsi/aic7xxx/aic79xx.h:1072: null expansion of name pattern "\3" ctags: Warning: drivers/scsi/aic7xxx/aic7xxx.h:919: null expansion of name pattern "\3" Signed-off-by: Michal Marek --- drivers/scsi/aic7xxx/aic79xx.h | 4 ++-- drivers/scsi/aic7xxx/aic79xx_osm.h | 5 ----- drivers/scsi/aic7xxx/aic7xxx.h | 2 +- drivers/scsi/aic7xxx/aic7xxx_osm.h | 5 ----- drivers/scsi/aic7xxx/queue.h | 2 +- 5 files changed, 4 insertions(+), 14 deletions(-) diff --git a/drivers/scsi/aic7xxx/aic79xx.h b/drivers/scsi/aic7xxx/aic79xx.h index df2e0e5367d2..d47b527b25dd 100644 --- a/drivers/scsi/aic7xxx/aic79xx.h +++ b/drivers/scsi/aic7xxx/aic79xx.h @@ -624,7 +624,7 @@ struct scb { }; TAILQ_HEAD(scb_tailq, scb); -LIST_HEAD(scb_list, scb); +BSD_LIST_HEAD(scb_list, scb); struct scb_data { /* @@ -1069,7 +1069,7 @@ struct ahd_softc { /* * SCBs that have been sent to the controller */ - LIST_HEAD(, scb) pending_scbs; + BSD_LIST_HEAD(, scb) pending_scbs; /* * Current register window mode information. diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.h b/drivers/scsi/aic7xxx/aic79xx_osm.h index c58fa33c6592..728193a42e6e 100644 --- a/drivers/scsi/aic7xxx/aic79xx_osm.h +++ b/drivers/scsi/aic7xxx/aic79xx_osm.h @@ -65,11 +65,6 @@ /* Core SCSI definitions */ #define AIC_LIB_PREFIX ahd -/* Name space conflict with BSD queue macros */ -#ifdef LIST_HEAD -#undef LIST_HEAD -#endif - #include "cam.h" #include "queue.h" #include "scsi_message.h" diff --git a/drivers/scsi/aic7xxx/aic7xxx.h b/drivers/scsi/aic7xxx/aic7xxx.h index f695774645c1..4ce4e903a759 100644 --- a/drivers/scsi/aic7xxx/aic7xxx.h +++ b/drivers/scsi/aic7xxx/aic7xxx.h @@ -916,7 +916,7 @@ struct ahc_softc { /* * SCBs that have been sent to the controller */ - LIST_HEAD(, scb) pending_scbs; + BSD_LIST_HEAD(, scb) pending_scbs; /* * Counting lock for deferring the release of additional diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm.h b/drivers/scsi/aic7xxx/aic7xxx_osm.h index bc4cca92ff04..54c702864103 100644 --- a/drivers/scsi/aic7xxx/aic7xxx_osm.h +++ b/drivers/scsi/aic7xxx/aic7xxx_osm.h @@ -82,11 +82,6 @@ /* Core SCSI definitions */ #define AIC_LIB_PREFIX ahc -/* Name space conflict with BSD queue macros */ -#ifdef LIST_HEAD -#undef LIST_HEAD -#endif - #include "cam.h" #include "queue.h" #include "scsi_message.h" diff --git a/drivers/scsi/aic7xxx/queue.h b/drivers/scsi/aic7xxx/queue.h index 8adf8003a164..ba602981f193 100644 --- a/drivers/scsi/aic7xxx/queue.h +++ b/drivers/scsi/aic7xxx/queue.h @@ -246,7 +246,7 @@ struct { \ /* * List declarations. */ -#define LIST_HEAD(name, type) \ +#define BSD_LIST_HEAD(name, type) \ struct name { \ struct type *lh_first; /* first element */ \ } -- cgit v1.2.3 From c26206f23a19af299540880ccf80e5a7af0f7db6 Mon Sep 17 00:00:00 2001 From: Michal Marek Date: Wed, 14 Oct 2015 10:55:04 +0200 Subject: tags: Fix erroneous pattern match in a comment Apparently, ctags applies the rules before deleting comments: ctags: Warning: include/linux/completion.h:22: null expansion of name pattern "\2" Work around this particular case by requiring the group to contain at least one character. Leave the other patters as they are, until a better solution is found. Signed-off-by: Michal Marek --- scripts/tags.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/tags.sh b/scripts/tags.sh index 25e30c30d1ad..2263f35be490 100755 --- a/scripts/tags.sh +++ b/scripts/tags.sh @@ -205,7 +205,7 @@ exuberant() --regex-c='/PCI_OP_WRITE\((\w*).*[1-4]\)/pci_bus_write_config_\1/' \ --regex-c='/DEFINE_(MUTEX|SEMAPHORE|SPINLOCK)\((\w*)/\2/v/' \ --regex-c='/DEFINE_(RAW_SPINLOCK|RWLOCK|SEQLOCK)\((\w*)/\2/v/' \ - --regex-c='/DECLARE_(RWSEM|COMPLETION)\((\w*)/\2/v/' \ + --regex-c='/DECLARE_(RWSEM|COMPLETION)\((\w+)/\2/v/' \ --regex-c='/DECLARE_BITMAP\((\w*)/\1/v/' \ --regex-c='/(^|\s)(|L|H)LIST_HEAD\((\w*)/\3/v/' \ --regex-c='/(^|\s)RADIX_TREE\((\w*)/\2/v/' \ -- cgit v1.2.3 From a281b8569e9eb4beb1651c92145271555ba05f0c Mon Sep 17 00:00:00 2001 From: Michal Marek Date: Wed, 14 Oct 2015 11:17:13 +0200 Subject: tags: Process Kconfig files in a single pass Signed-off-by: Michal Marek --- scripts/tags.sh | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/scripts/tags.sh b/scripts/tags.sh index 2263f35be490..b97d687784d5 100755 --- a/scripts/tags.sh +++ b/scripts/tags.sh @@ -220,10 +220,7 @@ exuberant() all_kconfigs | xargs $1 -a \ --langdef=kconfig --language-force=kconfig \ - --regex-kconfig='/^[[:blank:]]*(menu|)config[[:blank:]]+([[:alnum:]_]+)/\2/' - - all_kconfigs | xargs $1 -a \ - --langdef=kconfig --language-force=kconfig \ + --regex-kconfig='/^[[:blank:]]*(menu|)config[[:blank:]]+([[:alnum:]_]+)/\2/' \ --regex-kconfig='/^[[:blank:]]*(menu|)config[[:blank:]]+([[:alnum:]_]+)/CONFIG_\2/' all_defconfigs | xargs -r $1 -a \ @@ -271,9 +268,7 @@ emacs() --regex='/[^#]*DEFINE_HASHTABLE(\([^,)]*\)/\1/' all_kconfigs | xargs $1 -a \ - --regex='/^[ \t]*\(\(menu\)*config\)[ \t]+\([a-zA-Z0-9_]+\)/\3/' - - all_kconfigs | xargs $1 -a \ + --regex='/^[ \t]*\(\(menu\)*config\)[ \t]+\([a-zA-Z0-9_]+\)/\3/' \ --regex='/^[ \t]*\(\(menu\)*config\)[ \t]+\([a-zA-Z0-9_]+\)/CONFIG_\3/' all_defconfigs | xargs -r $1 -a \ -- cgit v1.2.3 From ab9ca615f5f4053417cba464015bf2d7334a2371 Mon Sep 17 00:00:00 2001 From: Michal Marek Date: Thu, 15 Oct 2015 11:14:02 +0200 Subject: tags: Do not try to index defconfigs The defconfig files are in predictable locations, so there is no need to index them. Plus, the script was only looking for files named 'defconfig', which only works on a few architectures nowadays. Signed-off-by: Michal Marek --- scripts/tags.sh | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/scripts/tags.sh b/scripts/tags.sh index b97d687784d5..e23427b6600a 100755 --- a/scripts/tags.sh +++ b/scripts/tags.sh @@ -134,11 +134,6 @@ all_kconfigs() find_other_sources 'Kconfig*' } -all_defconfigs() -{ - find_sources $ALLSOURCE_ARCHS "defconfig" -} - docscope() { (echo \-k; echo \-q; all_target_sources) > cscope.files @@ -222,10 +217,6 @@ exuberant() --langdef=kconfig --language-force=kconfig \ --regex-kconfig='/^[[:blank:]]*(menu|)config[[:blank:]]+([[:alnum:]_]+)/\2/' \ --regex-kconfig='/^[[:blank:]]*(menu|)config[[:blank:]]+([[:alnum:]_]+)/CONFIG_\2/' - - all_defconfigs | xargs -r $1 -a \ - --langdef=dotconfig --language-force=dotconfig \ - --regex-dotconfig='/^#?[[:blank:]]*(CONFIG_[[:alnum:]_]+)/\1/' } emacs() @@ -270,9 +261,6 @@ emacs() all_kconfigs | xargs $1 -a \ --regex='/^[ \t]*\(\(menu\)*config\)[ \t]+\([a-zA-Z0-9_]+\)/\3/' \ --regex='/^[ \t]*\(\(menu\)*config\)[ \t]+\([a-zA-Z0-9_]+\)/CONFIG_\3/' - - all_defconfigs | xargs -r $1 -a \ - --regex='/^#?[ \t]?\(CONFIG_[a-zA-Z0-9_]+\)/\1/' } xtags() -- cgit v1.2.3 From a1ccdb63b5535dc3446b0a9efc6d97aca82c72ef Mon Sep 17 00:00:00 2001 From: Michal Marek Date: Thu, 15 Oct 2015 15:12:51 +0200 Subject: tags: Drop the _PE rule We are not indexing the userspace tools, so the rules only match some false positives in the kernel code. Signed-off-by: Michal Marek --- scripts/tags.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/scripts/tags.sh b/scripts/tags.sh index e23427b6600a..14abf81188b5 100755 --- a/scripts/tags.sh +++ b/scripts/tags.sh @@ -189,7 +189,6 @@ exuberant() --regex-c='/__CLEARPAGEFLAG_NOOP\(([^,)]*).*/__ClearPage\1/' \ --regex-c='/TESTCLEARFLAG_FALSE\(([^,)]*).*/TestClearPage\1/' \ --regex-c='/__TESTCLEARFLAG_FALSE\(([^,)]*).*/__TestClearPage\1/' \ - --regex-c='/_PE\(([^,)]*).*/PEVENT_ERRNO__\1/' \ --regex-c='/TASK_PFA_TEST\([^,]*,\s*([^)]*)\)/task_\1/' \ --regex-c='/TASK_PFA_SET\([^,]*,\s*([^)]*)\)/task_set_\1/' \ --regex-c='/TASK_PFA_CLEAR\([^,]*,\s*([^)]*)\)/task_clear_\1/'\ @@ -253,7 +252,6 @@ emacs() --regex='/TASK_PFA_TEST\([^,]*,\s*([^)]*)\)/task_\1/' \ --regex='/TASK_PFA_SET\([^,]*,\s*([^)]*)\)/task_set_\1/' \ --regex='/TASK_PFA_CLEAR\([^,]*,\s*([^)]*)\)/task_clear_\1/' \ - --regex='/_PE(\([^,)]*\).*/PEVENT_ERRNO__\1/' \ --regex='/PCI_OP_READ(\([a-z]*[a-z]\).*[1-4])/pci_bus_read_config_\1/' \ --regex='/PCI_OP_WRITE(\([a-z]*[a-z]\).*[1-4])/pci_bus_write_config_\1/'\ --regex='/[^#]*DEFINE_HASHTABLE(\([^,)]*\)/\1/' -- cgit v1.2.3 From 93209d65c1d38f86ffb3f61a1214130b581a9709 Mon Sep 17 00:00:00 2001 From: Michal Marek Date: Wed, 14 Oct 2015 11:48:06 +0200 Subject: tags: Unify emacs and exuberant rules The emacs rules were constantly lagging behind the exuberant ones. Use a single set of rules for both, to make the script easier to maintain. The language understood by both tools is basic regular expression with some limitations, which are documented in a comment. To be able to store the rules in an array and easily iterate over it, the script requires bash now. In the exuberant case, the change fixes some false matches in and also some too greedy matches in the arguments of the DECLARE_*/DEFINE_* macros. In the emacs case, several previously not working rules are matching now. Tested with these versions of the tools: Exuberant Ctags 5.8, Copyright (C) 1996-2009 Darren Hiebert etags (GNU Emacs 24.5) Signed-off-by: Michal Marek --- scripts/tags.sh | 202 ++++++++++++++++++++++++++++++-------------------------- 1 file changed, 109 insertions(+), 93 deletions(-) diff --git a/scripts/tags.sh b/scripts/tags.sh index 14abf81188b5..bcc1d8cb142b 100755 --- a/scripts/tags.sh +++ b/scripts/tags.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # Generate tags or cscope files # Usage tags.sh # @@ -145,8 +145,108 @@ dogtags() all_target_sources | gtags -i -f - } +# Basic regular expressions with an optional /kind-spec/ for ctags and +# the following limitations: +# - No regex modifiers +# - Use \{0,1\} instead of \?, because etags expects an unescaped ? +# - \s is not working with etags, use a space or [ \t] +# - \w works, but does not match underscores in etags +# - etags regular expressions have to match at the start of a line; +# a ^[^#] is prepended by setup_regex unless an anchor is already present +regex_asm=( + '/^\(ENTRY\|_GLOBAL\)(\([[:alnum:]_\\]*\)).*/\2/' +) +regex_c=( + '/^SYSCALL_DEFINE[0-9](\([[:alnum:]_]*\).*/sys_\1/' + '/^COMPAT_SYSCALL_DEFINE[0-9](\([[:alnum:]_]*\).*/compat_sys_\1/' + '/^TRACE_EVENT(\([[:alnum:]_]*\).*/trace_\1/' + '/^TRACE_EVENT(\([[:alnum:]_]*\).*/trace_\1_rcuidle/' + '/^DEFINE_EVENT([^,)]*, *\([[:alnum:]_]*\).*/trace_\1/' + '/^DEFINE_EVENT([^,)]*, *\([[:alnum:]_]*\).*/trace_\1_rcuidle/' + '/^PAGEFLAG(\([[:alnum:]_]*\).*/Page\1/' + '/^PAGEFLAG(\([[:alnum:]_]*\).*/SetPage\1/' + '/^PAGEFLAG(\([[:alnum:]_]*\).*/ClearPage\1/' + '/^TESTSETFLAG(\([[:alnum:]_]*\).*/TestSetPage\1/' + '/^TESTPAGEFLAG(\([[:alnum:]_]*\).*/Page\1/' + '/^SETPAGEFLAG(\([[:alnum:]_]*\).*/SetPage\1/' + '/\<__SETPAGEFLAG(\([[:alnum:]_]*\).*/__SetPage\1/' + '/\ Date: Thu, 7 Jan 2016 10:36:51 +0100 Subject: coccinelle: tests: unsigned value cannot be lesser than zero Unsigned expressions cannot be lesser than zero. Presence of comparisons 'unsigned (<|<=|>|>=) 0' often indicates a bug, usually wrong type of variable. The patch beside finding such comparisons tries to eliminate false positives, mainly by bypassing range checks. gcc can detect such comparisons also using -Wtype-limits switch, but it warns also in correct cases, making too much noise. Signed-off-by: Andrzej Hajda Acked-by: Julia Lawall Signed-off-by: Michal Marek --- .../tests/unsigned_lesser_than_zero.cocci | 75 ++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 scripts/coccinelle/tests/unsigned_lesser_than_zero.cocci diff --git a/scripts/coccinelle/tests/unsigned_lesser_than_zero.cocci b/scripts/coccinelle/tests/unsigned_lesser_than_zero.cocci new file mode 100644 index 000000000000..8fa5a3c7b784 --- /dev/null +++ b/scripts/coccinelle/tests/unsigned_lesser_than_zero.cocci @@ -0,0 +1,75 @@ +/// Unsigned expressions cannot be lesser than zero. Presence of +/// comparisons 'unsigned (<|<=|>|>=) 0' often indicates a bug, +/// usually wrong type of variable. +/// +/// To reduce number of false positives following tests have been added: +/// - parts of range checks are skipped, eg. "if (u < 0 || u > 15) ...", +/// developers prefer to keep such code, +/// - comparisons "<= 0" and "> 0" are performed only on results of +/// signed functions/macros, +/// - hardcoded list of signed functions/macros with always non-negative +/// result is used to avoid false positives difficult to detect by other ways +/// +// Confidence: Average +// Copyright: (C) 2015 Andrzej Hajda, Samsung Electronics Co., Ltd. GPLv2. +// URL: http://coccinelle.lip6.fr/ +// Options: --all-includes + +virtual context +virtual org +virtual report + +@r_cmp@ +position p; +typedef bool, u8, u16, u32, u64; +{unsigned char, unsigned short, unsigned int, unsigned long, unsigned long long, + size_t, bool, u8, u16, u32, u64} v; +expression e; +@@ + + \( v = e \| &v \) + ... + (\( v@p < 0 \| v@p <= 0 \| v@p >= 0 \| v@p > 0 \)) + +@r@ +position r_cmp.p; +typedef s8, s16, s32, s64; +{char, short, int, long, long long, ssize_t, s8, s16, s32, s64} vs; +expression c, e, v; +identifier f !~ "^(ata_id_queue_depth|btrfs_copy_from_user|dma_map_sg|dma_map_sg_attrs|fls|fls64|gameport_time|get_write_extents|nla_len|ntoh24|of_flat_dt_match|of_get_child_count|uart_circ_chars_pending|[A-Z0-9_]+)$"; +@@ + +( + v = f(...)@vs; + ... when != v = e; +* (\( v@p <=@e 0 \| v@p >@e 0 \)) + ... when any +| +( + (\( v@p < 0 \| v@p <= 0 \)) || ... || (\( v >= c \| v > c \)) +| + (\( v >= c \| v > c \)) || ... || (\( v@p < 0 \| v@p <= 0 \)) +| + (\( v@p >= 0 \| v@p > 0 \)) && ... && (\( v < c \| v <= c \)) +| + ((\( v < c \| v <= c \) && ... && \( v@p >= 0 \| v@p > 0 \))) +| +* (\( v@p <@e 0 \| v@p >=@e 0 \)) +) +) + +@script:python depends on org@ +p << r_cmp.p; +e << r.e; +@@ + +msg = "WARNING: Unsigned expression compared with zero: %s" % (e) +coccilib.org.print_todo(p[0], msg) + +@script:python depends on report@ +p << r_cmp.p; +e << r.e; +@@ + +msg = "WARNING: Unsigned expression compared with zero: %s" % (e) +coccilib.report.print_report(p[0], msg) -- cgit v1.2.3