From b22ae40ef2e7847ddbd802d1a887188e113675f3 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Fri, 8 Aug 2014 17:23:07 +0200 Subject: [PATCH 01/11] Documentation: kbuild: Remove obsolete include/asm symlink step As of commit f7f16b7799ed68654850ab340ef812895aebcf4c ("kbuild: drop include/asm"), the include/asm symlink is no longer created. Signed-off-by: Geert Uytterhoeven Signed-off-by: Michal Marek --- Documentation/kbuild/makefiles.txt | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt index 764f5991a3fc..a445e1c8828e 100644 --- a/Documentation/kbuild/makefiles.txt +++ b/Documentation/kbuild/makefiles.txt @@ -818,17 +818,16 @@ a few targets. When kbuild executes, the following steps are followed (roughly): 1) Configuration of the kernel => produce .config 2) Store kernel version in include/linux/version.h -3) Symlink include/asm to include/asm-$(ARCH) -4) Updating all other prerequisites to the target prepare: +3) Updating all other prerequisites to the target prepare: - Additional prerequisites are specified in arch/$(ARCH)/Makefile -5) Recursively descend down in all directories listed in +4) Recursively descend down in all directories listed in init-* core* drivers-* net-* libs-* and build all targets. - The values of the above variables are expanded in arch/$(ARCH)/Makefile. -6) All object files are then linked and the resulting file vmlinux is +5) All object files are then linked and the resulting file vmlinux is located at the root of the obj tree. The very first objects linked are listed in head-y, assigned by arch/$(ARCH)/Makefile. -7) Finally, the architecture-specific part does any required post processing +6) Finally, the architecture-specific part does any required post processing and builds the final bootimage. - This includes building boot records - Preparing initrd images and the like From ef80f0a1e033bcab17257e2155a3c9263a0919c1 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Fri, 8 Aug 2014 17:23:08 +0200 Subject: [PATCH 02/11] Documentation: kbuild: Improve if_changed documentation - These days if_changed is used with many more commands than ld, objcopy, and gzip, hence add an ellipsis, - Any target that utilises if_changed must be listed in $(targets), so it needs an assignment to "targets", not "target". Signed-off-by: Geert Uytterhoeven Signed-off-by: Michal Marek --- Documentation/kbuild/makefiles.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt index a445e1c8828e..520b2c75bc56 100644 --- a/Documentation/kbuild/makefiles.txt +++ b/Documentation/kbuild/makefiles.txt @@ -1092,7 +1092,7 @@ When kbuild executes, the following steps are followed (roughly): Usage: target: source(s) FORCE - $(call if_changed,ld/objcopy/gzip) + $(call if_changed,ld/objcopy/gzip/...) When the rule is evaluated, it is checked to see if any files need an update, or the command line has changed since the last @@ -1110,7 +1110,7 @@ When kbuild executes, the following steps are followed (roughly): significant; for instance, the below will fail (note the extra space after the comma): target: source(s) FORCE - #WRONG!# $(call if_changed, ld/objcopy/gzip) + #WRONG!# $(call if_changed, ld/objcopy/gzip/...) ld Link target. Often, LDFLAGS_$@ is used to set specific options to ld. @@ -1142,7 +1142,7 @@ When kbuild executes, the following steps are followed (roughly): The ": %: %.o" part of the prerequisite is a shorthand that free us from listing the setup.o and bootsect.o files. - Note: It is a common mistake to forget the "target :=" assignment, + Note: It is a common mistake to forget the "targets :=" assignment, resulting in the target file being recompiled for no obvious reason. From cf6c53db9525a7f6c5052ccd84a0638128f14632 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Fri, 8 Aug 2014 17:23:09 +0200 Subject: [PATCH 03/11] Documentation: kbuild: Remove obsolete dtc_cpp section Commit b40b25fff8205dd18124d8fc87b2c9c57f269b5f ("kbuild: always run gcc -E on *.dts, remove cmd_dtc_cpp") improved the functionality of cmd_dtc_cpp and merged it back into cmd_dtc. Signed-off-by: Geert Uytterhoeven Signed-off-by: Michal Marek --- Documentation/kbuild/makefiles.txt | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt index 520b2c75bc56..eda00a1073a7 100644 --- a/Documentation/kbuild/makefiles.txt +++ b/Documentation/kbuild/makefiles.txt @@ -1163,29 +1163,6 @@ When kbuild executes, the following steps are followed (roughly): clean-files += *.dtb DTC_FLAGS ?= -p 1024 - dtc_cpp - This is just like dtc as describe above, except that the C pre- - processor is invoked upon the .dtsp file before compiling the result - with dtc. - - In order for build dependencies to work, all files compiled using - dtc_cpp must use the C pre-processor's #include functionality and not - dtc's /include/ functionality. - - Using the C pre-processor allows use of #define to create named - constants. In turn, the #defines will typically appear in a header - file, which may be shared with regular C code. Since the dtc language - represents a data structure rather than code in C syntax, similar - restrictions are placed on a header file included by a device tree - file as for a header file included by an assembly language file. - In particular, the C pre-processor is passed -x assembler-with-cpp, - which sets macro __ASSEMBLY__. __DTS__ is also set. These allow header - files to restrict their content to that compatible with device tree - source. - - A central rule exists to create $(obj)/%.dtb from $(src)/%.dtsp; - architecture Makefiles do no need to explicitly write out that rule. - --- 6.8 Custom kbuild commands When kbuild is executing with KBUILD_VERBOSE=0, then only a shorthand From 39fed7015cd9124b5893fce18d33f49db1c48bea Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Fri, 8 Aug 2014 17:23:10 +0200 Subject: [PATCH 04/11] Documentation: kbuild: Improve grammar - singular versus plural, - "by" versus "of", - missing "if", "it", "the", - consistent use of "xxx-specific" versus "xxx specific". Signed-off-by: Geert Uytterhoeven Acked-by: Randy Dunlap Signed-off-by: Michal Marek --- Documentation/kbuild/makefiles.txt | 56 +++++++++++++++--------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt index eda00a1073a7..a311db829e9b 100644 --- a/Documentation/kbuild/makefiles.txt +++ b/Documentation/kbuild/makefiles.txt @@ -174,7 +174,7 @@ more details, with real examples. --- 3.3 Loadable module goals - obj-m - $(obj-m) specify object files which are built as loadable + $(obj-m) specifies object files which are built as loadable kernel modules. A module may be built from one source file or several source @@ -277,7 +277,7 @@ more details, with real examples. down in the ext2 directory. Kbuild only uses this information to decide that it needs to visit the directory, it is the Makefile in the subdirectory that - specifies what is modules and what is built-in. + specifies what is modular and what is built-in. It is good practice to use a CONFIG_ variable when assigning directory names. This allows kbuild to totally skip the directory if the @@ -403,7 +403,7 @@ more details, with real examples. echoing information to user in a rule is often a good practice but when execution "make -s" one does not expect to see any output except for warnings/errors. - To support this kbuild define $(kecho) which will echo out the + To support this kbuild defines $(kecho) which will echo out the text following $(kecho) to stdout except if "make -s" is used. Example: @@ -417,7 +417,7 @@ more details, with real examples. The kernel may be built with several different versions of $(CC), each supporting a unique set of features and options. - kbuild provide basic support to check for valid options for $(CC). + kbuild provides basic support to check for valid options for $(CC). $(CC) is usually the gcc compiler, but other alternatives are available. @@ -456,8 +456,8 @@ more details, with real examples. Note: as-instr-option uses KBUILD_AFLAGS for $(AS) options cc-option - cc-option is used to check if $(CC) supports a given option, and not - supported to use an optional second option. + cc-option is used to check if $(CC) supports a given option, and if + not supported to use an optional second option. Example: #arch/x86/Makefile @@ -557,8 +557,8 @@ more details, with real examples. false ; \ fi - In this example for a specific GCC version the build will error out explaining - to the user why it stops. + In this example for a specific GCC version the build will error out + explaining to the user why it stops. cc-cross-prefix cc-cross-prefix is used to check if there exists a $(CC) in path with @@ -656,7 +656,7 @@ Both possibilities are described in the following. In the example above the executable is composed of the C++ file qconf.cc - identified by $(qconf-cxxobjs). - If qconf is composed by a mixture of .c and .cc files, then an + If qconf is composed of a mixture of .c and .cc files, then an additional line can be used to identify this. Example: @@ -733,7 +733,7 @@ Both possibilities are described in the following. hostprogs-$(CONFIG_KALLSYMS) += kallsyms Kbuild knows about both 'y' for built-in and 'm' for module. - So if a config symbol evaluate to 'm', kbuild will still build + So if a config symbol evaluates to 'm', kbuild will still build the binary. In other words, Kbuild handles hostprogs-m exactly like hostprogs-y. But only hostprogs-y is recommended to be used when no CONFIG symbols are involved. @@ -754,8 +754,8 @@ Additional files can be specified in kbuild makefiles by use of $(clean-files). #drivers/pci/Makefile clean-files := devlist.h classlist.h -When executing "make clean", the two files "devlist.h classlist.h" will -be deleted. Kbuild will assume files to be in same relative directory as the +When executing "make clean", the two files "devlist.h classlist.h" will be +deleted. Kbuild will assume files to be in the same relative directory as the Makefile except if an absolute path is specified (path starting with '/'). To delete a directory hierarchy use: @@ -786,7 +786,7 @@ is not sufficient this sometimes needs to be explicit. The above assignment instructs kbuild to descend down in the directory compressed/ when "make clean" is executed. -To support the clean infrastructure in the Makefiles that builds the +To support the clean infrastructure in the Makefiles that build the final bootimage there is an optional target named archclean: Example: @@ -926,7 +926,7 @@ When kbuild executes, the following steps are followed (roughly): KBUILD_AFLAGS_MODULE Options for $(AS) when building modules - $(KBUILD_AFLAGS_MODULE) is used to add arch specific options that + $(KBUILD_AFLAGS_MODULE) is used to add arch-specific options that are used for $(AS). From commandline AFLAGS_MODULE shall be used (see kbuild.txt). @@ -937,13 +937,13 @@ When kbuild executes, the following steps are followed (roughly): KBUILD_CFLAGS_MODULE Options for $(CC) when building modules - $(KBUILD_CFLAGS_MODULE) is used to add arch specific options that + $(KBUILD_CFLAGS_MODULE) is used to add arch-specific options that are used for $(CC). From commandline CFLAGS_MODULE shall be used (see kbuild.txt). KBUILD_LDFLAGS_MODULE Options for $(LD) when linking modules - $(KBUILD_LDFLAGS_MODULE) is used to add arch specific options + $(KBUILD_LDFLAGS_MODULE) is used to add arch-specific options used when linking modules. This is often a linker script. From commandline LDFLAGS_MODULE shall be used (see kbuild.txt). @@ -1065,7 +1065,7 @@ When kbuild executes, the following steps are followed (roughly): extra-y - extra-y specify additional targets created in the current + extra-y specifies additional targets created in the current directory, in addition to any targets specified by obj-*. Listing all targets in extra-y is required for two purposes: @@ -1141,7 +1141,7 @@ When kbuild executes, the following steps are followed (roughly): 2) delete target during make clean The ": %: %.o" part of the prerequisite is a shorthand that - free us from listing the setup.o and bootsect.o files. + frees us from listing the setup.o and bootsect.o files. Note: It is a common mistake to forget the "targets :=" assignment, resulting in the target file being recompiled for no obvious reason. @@ -1213,11 +1213,11 @@ When kbuild executes, the following steps are followed (roughly): When building the *.lds target, kbuild uses the variables: KBUILD_CPPFLAGS : Set in top-level Makefile cppflags-y : May be set in the kbuild makefile - CPPFLAGS_$(@F) : Target specific flags. + CPPFLAGS_$(@F) : Target-specific flags. Note that the full filename is used in this assignment. - The kbuild infrastructure for *lds file are used in several + The kbuild infrastructure for *lds files is used in several architecture-specific files. --- 6.10 Generic header files @@ -1230,11 +1230,11 @@ When kbuild executes, the following steps are followed (roughly): === 7 Kbuild syntax for exported headers -The kernel include a set of headers that is exported to userspace. +The kernel includes a set of headers that is exported to userspace. Many headers can be exported as-is but other headers require a minimal pre-processing before they are ready for user-space. The pre-processing does: -- drop kernel specific annotations +- drop kernel-specific annotations - drop include of compiler.h - drop all sections that are kernel internal (guarded by ifdef __KERNEL__) @@ -1244,7 +1244,7 @@ See subsequent chapter for the syntax of the Kbuild file. --- 7.1 header-y - header-y specify header files to be exported. + header-y specifies header files to be exported. Example: #include/linux/Kbuild @@ -1254,7 +1254,7 @@ See subsequent chapter for the syntax of the Kbuild file. The convention is to list one file per line and preferably in alphabetic order. - header-y also specify which subdirectories to visit. + header-y also specifies which subdirectories to visit. A subdirectory is identified by a trailing '/' which can be seen in the example above for the usb subdirectory. @@ -1272,9 +1272,9 @@ See subsequent chapter for the syntax of the Kbuild file. --- 7.3 destination-y - When an architecture have a set of exported headers that needs to be + When an architecture has a set of exported headers that needs to be exported to a different directory destination-y is used. - destination-y specify the destination directory for all exported + destination-y specifies the destination directory for all exported headers in the file where it is present. Example: @@ -1367,9 +1367,9 @@ The top Makefile exports the following variables: INSTALL_MOD_STRIP - If this variable is specified, will cause modules to be stripped + If this variable is specified, it will cause modules to be stripped after they are installed. If INSTALL_MOD_STRIP is '1', then the - default option --strip-debug will be used. Otherwise, + default option --strip-debug will be used. Otherwise, the INSTALL_MOD_STRIP value will be used as the option(s) to the strip command. From 8bf4abaddd01aa6c9d13804fa05084cb28135a47 Mon Sep 17 00:00:00 2001 From: Dirk Gouders Date: Sat, 16 Aug 2014 07:56:56 +0200 Subject: [PATCH 05/11] scripts/tags.sh: Don't specify kind-spec for emacs' ctags/etags Emacs' ctags/etags don't know about kind-spec in --regex and produce warnings: etags: invalid regexp modifier `v', ignoring etags: invalid regexp modifier `/', ignoring Fix it by removing kind-spec for the emacs case. Signed-off-by: Dirk Gouders Inspired-by: Masatake YAMATO Tested-by: Masatake YAMATO 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 cbfd269a6011..727989757d59 100755 --- a/scripts/tags.sh +++ b/scripts/tags.sh @@ -263,7 +263,7 @@ emacs() --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\((\w*)/\1/v/' + --regex='/DEFINE_HASHTABLE\((\w*)/\1/' all_kconfigs | xargs $1 -a \ --regex='/^[ \t]*\(\(menu\)*config\)[ \t]+\([a-zA-Z0-9_]+\)/\3/' From a60113d6a7fca3320e84d25db84c3c1a5a02b505 Mon Sep 17 00:00:00 2001 From: Dirk Gouders Date: Sat, 16 Aug 2014 07:56:57 +0200 Subject: [PATCH 06/11] scripts/tags.sh: remove *PCGFLAGS regular expressions Commit 0a31bc97c80c3fa8 (mm: memcontrol: rewrite uncharge API) removed the macros {TEST,SET,CLEAR,TESTCLEAR}PCFLAG. Remove corresponding entries from tags.sh -- in the emacs case they also produced warnigs because of unmatched '\('. Signed-off-by: Dirk Gouders Inspired-by: Masatake YAMATO Signed-off-by: Michal Marek --- scripts/tags.sh | 8 -------- 1 file changed, 8 deletions(-) diff --git a/scripts/tags.sh b/scripts/tags.sh index 727989757d59..0f61bd7ee958 100755 --- a/scripts/tags.sh +++ b/scripts/tags.sh @@ -193,10 +193,6 @@ exuberant() --regex-c++='/TESTCLEARFLAG_FALSE\(([^,)]*).*/TestClearPage\1/' \ --regex-c++='/__TESTCLEARFLAG_FALSE\(([^,)]*).*/__TestClearPage\1/' \ --regex-c++='/_PE\(([^,)]*).*/PEVENT_ERRNO__\1/' \ - --regex-c++='/TESTPCGFLAG\(([^,)]*).*/PageCgroup\1/' \ - --regex-c++='/SETPCGFLAG\(([^,)]*).*/SetPageCgroup\1/' \ - --regex-c++='/CLEARPCGFLAG\(([^,)]*).*/ClearPageCgroup\1/' \ - --regex-c++='/TESTCLEARPCGFLAG\(([^,)]*).*/TestClearPageCgroup\1/' \ --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/' \ @@ -256,10 +252,6 @@ emacs() --regex='/__CLEARPAGEFLAG_NOOP(\([^,)]*\).*/__ClearPage\1/' \ --regex='/TESTCLEARFLAG_FALSE(\([^,)]*\).*/TestClearPage\1/' \ --regex='/__TESTCLEARFLAG_FALSE(\([^,)]*\).*/__TestClearPage\1/' \ - --regex='/TESTPCGFLAG\(([^,)]*).*/PageCgroup\1/' \ - --regex='/SETPCGFLAG\(([^,)]*).*/SetPageCgroup\1/' \ - --regex='/CLEARPCGFLAG\(([^,)]*).*/ClearPageCgroup\1/' \ - --regex='/TESTCLEARPCGFLAG\(([^,)]*).*/TestClearPageCgroup\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/'\ From 8e170655b517ba49bf4d015008474bcc2f425b20 Mon Sep 17 00:00:00 2001 From: Dirk Gouders Date: Sat, 16 Aug 2014 07:56:58 +0200 Subject: [PATCH 07/11] scripts/tags.sh: fix DEFINE_HASHTABLE in emacs case The emacs --regex for DEFINE_HASHTABLE produced a warning because of an unmatched '\('. Further, the whole entry did not work, because the regex needs to match from the beginning of a line, including keywords like 'static'. Finally, '\w' should not be used, because it stops at underscores which are often part of variable names in C, resulting in wrong entries in the tags file. Signed-off-by: Dirk Gouders Inspired-by: Masatake YAMATO 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 0f61bd7ee958..fd651f90a838 100755 --- a/scripts/tags.sh +++ b/scripts/tags.sh @@ -255,7 +255,7 @@ emacs() --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\((\w*)/\1/' + --regex='/[^#]*DEFINE_HASHTABLE(\([^,)]*\)/\1/' all_kconfigs | xargs $1 -a \ --regex='/^[ \t]*\(\(menu\)*config\)[ \t]+\([a-zA-Z0-9_]+\)/\3/' From 2d0871396995139b37f9ceb153c8b07589148343 Mon Sep 17 00:00:00 2001 From: Michal Marek Date: Fri, 22 Aug 2014 15:51:03 +0200 Subject: [PATCH 08/11] builddeb: put the dbg files into the correct directory Since the conversion of objtree to use relative pathnames (commit 7e1c04779e, "kbuild: Use relative path for $(objtree)"), the debug info files have been ending up in /debian/dbgtmp/ in the regular linux-image package instead of the debug files package. Fix up the paths so that the debug files end up in the -dbg package. This is based on a similar patch by Darrick. Reported-and-tested-by: "Darrick J. Wong" Signed-off-by: Michal Marek --- scripts/package/builddeb | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/scripts/package/builddeb b/scripts/package/builddeb index 35d5a5877d04..7c0e6e46905d 100644 --- a/scripts/package/builddeb +++ b/scripts/package/builddeb @@ -152,18 +152,16 @@ if grep -q '^CONFIG_MODULES=y' $KCONFIG_CONFIG ; then rmdir "$tmpdir/lib/modules/$version" fi if [ -n "$BUILD_DEBUG" ] ; then - ( - cd $tmpdir - for module in $(find lib/modules/ -name *.ko); do - mkdir -p $(dirname $dbg_dir/usr/lib/debug/$module) - # only keep debug symbols in the debug file - $OBJCOPY --only-keep-debug $module $dbg_dir/usr/lib/debug/$module - # strip original module from debug symbols - $OBJCOPY --strip-debug $module - # then add a link to those - $OBJCOPY --add-gnu-debuglink=$dbg_dir/usr/lib/debug/$module $module - done - ) + for module in $(find $tmpdir/lib/modules/ -name *.ko -printf '%P\n'); do + module=lib/modules/$module + mkdir -p $(dirname $dbg_dir/usr/lib/debug/$module) + # only keep debug symbols in the debug file + $OBJCOPY --only-keep-debug $tmpdir/$module $dbg_dir/usr/lib/debug/$module + # strip original module from debug symbols + $OBJCOPY --strip-debug $tmpdir/$module + # then add a link to those + $OBJCOPY --add-gnu-debuglink=$dbg_dir/usr/lib/debug/$module $tmpdir/$module + done fi fi From 22739edfc563fa42f02a2f7323fd352061ef32b3 Mon Sep 17 00:00:00 2001 From: Michael Neuling Date: Fri, 5 Sep 2014 17:55:18 +1000 Subject: [PATCH 09/11] deb-pkg: Add support for powerpc little endian The Debian powerpc little endian architecture is called ppc64el. This is the default architecture used by Ubuntu for powerpc. The below checks the kernel config to see if we are compiling little endian and sets the Debian arch appropriately. Signed-off-by: Michael Neuling Signed-off-by: Michal Marek --- scripts/package/builddeb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/package/builddeb b/scripts/package/builddeb index 7c0e6e46905d..cfe5e27dd09e 100644 --- a/scripts/package/builddeb +++ b/scripts/package/builddeb @@ -37,7 +37,7 @@ create_package() { s390*) debarch=s390$(grep -q CONFIG_64BIT=y $KCONFIG_CONFIG && echo x || true) ;; ppc*) - debarch=powerpc ;; + debarch=$(grep -q CPU_LITTLE_ENDIAN=y $KCONFIG_CONFIG && echo ppc64el || echo powerpc) ;; parisc*) debarch=hppa ;; mips*) From 932058a5d5f9fd919b90aaa2275d54b37340d585 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Sat, 23 Aug 2014 07:34:45 +0200 Subject: [PATCH 10/11] coccinelle: misc: semantic patch to delete overly complex return code processing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This semantic patch simplifies cases where the effect of the processing of a function call's return code is just to return the result of the function directly. It may also delete a local return flag variable, if this is no longer used. This was proposed by Uwe Kleine-König. Signed-off-by: Julia Lawall Signed-off-by: Michal Marek --- scripts/coccinelle/misc/simple_return.cocci | 180 ++++++++++++++++++++ 1 file changed, 180 insertions(+) create mode 100644 scripts/coccinelle/misc/simple_return.cocci diff --git a/scripts/coccinelle/misc/simple_return.cocci b/scripts/coccinelle/misc/simple_return.cocci new file mode 100644 index 000000000000..47f7084b6360 --- /dev/null +++ b/scripts/coccinelle/misc/simple_return.cocci @@ -0,0 +1,180 @@ +/// Simplify a trivial if-return sequence. Possibly combine with a +/// preceding function call. +// +// Confidence: High +// Copyright: (C) 2014 Julia Lawall, INRIA/LIP6. GPLv2. +// Copyright: (C) 2014 Gilles Muller, INRIA/LiP6. GPLv2. +// URL: http://coccinelle.lip6.fr/ +// Comments: +// Options: --no-includes --include-headers + +virtual patch +virtual context +virtual org +virtual report + +@r depends on patch@ +local idexpression e; +identifier i,f,fn; +@@ + +fn(...) { <... +- e@i = ++ return + f(...); +-if (i != 0) return i; +-return 0; +...> } + +@depends on patch@ +identifier r.i; +type t; +@@ + +-t i; + ... when != i + +@depends on patch@ +expression e; +@@ + +-if (e != 0) + return e; +-return 0; + +// ----------------------------------------------------------------------- + +@s1 depends on context || org || report@ +local idexpression e; +identifier i,f,fn; +position p,p1,p2; +@@ + +fn(...) { <... +* e@i@p = f(...); + if (\(i@p1 != 0\|i@p2 < 0\)) + return i; + return 0; +...> } + +@s2 depends on context || org || report forall@ +identifier s1.i; +type t; +position q,s1.p; +expression e,f; +@@ + +* t i@q; + ... when != i + e@p = f(...); + +@s3 depends on context || org || report@ +expression e; +position p1!=s1.p1; +position p2!=s1.p2; +@@ + +*if (\(e@p1 != 0\|e@p2 < 0\)) + return e; + return 0; + +// ----------------------------------------------------------------------- + +@script:python depends on org@ +p << s1.p; +p1 << s1.p1; +q << s2.q; +@@ + +cocci.print_main("decl",q) +cocci.print_secs("use",p) +cocci.include_match(False) + +@script:python depends on org@ +p << s1.p; +p2 << s1.p2; +q << s2.q; +@@ + +cocci.print_main("decl",q) +cocci.print_secs("use with questionable test",p) +cocci.include_match(False) + +@script:python depends on org@ +p << s1.p; +p1 << s1.p1; +@@ + +cocci.print_main("use",p) + +@script:python depends on org@ +p << s1.p; +p2 << s1.p2; +@@ + +cocci.print_main("use with questionable test",p) + +@script:python depends on org@ +p << s3.p1; +@@ + +cocci.print_main("test",p) + +@script:python depends on org@ +p << s3.p2; +@@ + +cocci.print_main("questionable test",p) + +// ----------------------------------------------------------------------- + +@script:python depends on report@ +p << s1.p; +p1 << s1.p1; +q << s2.q; +@@ + +msg = "WARNING: end returns can be simpified and declaration on line %s can be dropped" % (q[0].line) +coccilib.report.print_report(p[0],msg) +cocci.include_match(False) + +@script:python depends on report@ +p << s1.p; +p1 << s1.p1; +q << s2.q +; +@@ + +msg = "WARNING: end returns may be simpified if negative or 0 value and declaration on line %s can be dropped" % (q[0].line) +coccilib.report.print_report(p[0],msg) +cocci.include_match(False) + +@script:python depends on report@ +p << s1.p; +p1 << s1.p1; +@@ + +msg = "WARNING: end returns can be simpified" +coccilib.report.print_report(p[0],msg) + +@script:python depends on report@ +p << s1.p; +p2 << s1.p2; +@@ + +msg = "WARNING: end returns can be simpified if negative or 0 value" +coccilib.report.print_report(p[0],msg) + +@script:python depends on report@ +p << s3.p1; +@@ + +msg = "WARNING: end returns can be simpified" +coccilib.report.print_report(p[0],msg) + +@script:python depends on report@ +p << s3.p2; +@@ + +msg = "WARNING: end returns can be simpified if tested value is negative or 0" +coccilib.report.print_report(p[0],msg) From 4204111c028d492019e4440d12e9e3d062db4283 Mon Sep 17 00:00:00 2001 From: Asbjoern Sloth Toennesen Date: Sun, 5 Oct 2014 17:43:18 +0000 Subject: [PATCH 11/11] deb-pkg: remove obsolete -isp option to dpkg-gencontrol The -isp option has been deprecated, after it became the default behaviour back in 2006. Since dpkg 1.17.11, dpkg-gencontrol emits a warning on -isp usage. References: https://bugs.debian.org/215233 Signed-off-by: Asbjoern Sloth Toennesen Signed-off-by: Michal Marek --- scripts/package/builddeb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/package/builddeb b/scripts/package/builddeb index cfe5e27dd09e..59726243c2eb 100644 --- a/scripts/package/builddeb +++ b/scripts/package/builddeb @@ -64,7 +64,7 @@ create_package() { fi # Create the package - dpkg-gencontrol -isp $forcearch -Vkernel:debarch="${debarch:-$(dpkg --print-architecture)}" -p$pname -P"$pdir" + dpkg-gencontrol $forcearch -Vkernel:debarch="${debarch:-$(dpkg --print-architecture)}" -p$pname -P"$pdir" dpkg --build "$pdir" .. }