[libvirt PATCH 0/9] syntax-check: fix sc-prohibit-cross-inclusion

And drop some legacy stuff, since I already had to open the file. Ján Tomko (9): syntax-check: do not enforce ChangeLog syntax syntax-check: fix sc-prohibit-cross-inclusion syntax-check: drop vulnerable Makefile checks syntax-check: drop CVS keyword expansion check syntax-check: drop update-NEWS-hash syntax-check: exclude: remove deleted files syntax-check: exclude: remove virstring syntax-check: remove README syntax-check: remove some exception mechanisms build-aux/syntax-check.mk | 73 +++------------------------------------ 1 file changed, 5 insertions(+), 68 deletions(-) -- 2.24.1

Our last conforming ChangeLog was removed from git in 2009 by: commit 27b175b9a254d5dc4bbc1d6f198f58b287e516a2 generate ChangeLog from git logs into distribution tarball Ten years later, it reappeared in: commit ce97c33a795dec053f1e85c65ecd924b8c6ec4ba maint: Stop generating ChangeLog from git which does not have a single line complying to this syntax check rule. At some point between the two commits VC_LIST_EXCEPT gained a default exception for ChangeLog and it did not seem to be overriden anywhere. Just remove the rule. Signed-off-by: Ján Tomko <jtomko@redhat.com> --- build-aux/syntax-check.mk | 7 ------- 1 file changed, 7 deletions(-) diff --git a/build-aux/syntax-check.mk b/build-aux/syntax-check.mk index 5886b82003..80420eada5 100644 --- a/build-aux/syntax-check.mk +++ b/build-aux/syntax-check.mk @@ -1616,13 +1616,6 @@ sc_prohibit_dirent_without_use: sc_prohibit_xfreopen_without_use: @h='xfreopen.h' re='\<xfreopen *\(' $(_sc_header_without_use) -# Each nonempty ChangeLog line must start with a year number, or a TAB. -sc_changelog: - @prohibit='^[^12 ]' \ - in_vc_files='^ChangeLog$$' \ - halt='found unexpected prefix in a ChangeLog' \ - $(_sc_search_regexp) - # Ensure that each .c file containing a "main" function also # calls bindtextdomain. sc_bindtextdomain: -- 2.24.1

Using '^' in in_vc_files assumes the build is happening in srcdir, which is no longer possible as of: commit f96395e78eaccffbf128336382c74b1250f04032 Signed-off-by: Ján Tomko <jtomko@redhat.com> --- build-aux/syntax-check.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-aux/syntax-check.mk b/build-aux/syntax-check.mk index 80420eada5..58a24b6276 100644 --- a/build-aux/syntax-check.mk +++ b/build-aux/syntax-check.mk @@ -871,7 +871,7 @@ sc_prohibit_cross_inclusion: safe="($$dir|util|conf|storage)";; \ *) safe="($$dir|$(mid_dirs)|util)";; \ esac; \ - in_vc_files="^src/$$dir" \ + in_vc_files="src/$$dir" \ prohibit='^# *include .$(cross_dirs_re)' \ exclude="# *include .$$safe" \ halt='unsafe cross-directory include' \ -- 2.24.1

As foretold, fixed automake is so common nowadays even Ubuntu 16.04 and Debian 9 have 1.11.6 as the oldest available version. Signed-off-by: Ján Tomko <jtomko@redhat.com> --- build-aux/syntax-check.mk | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/build-aux/syntax-check.mk b/build-aux/syntax-check.mk index 58a24b6276..52a6062ad5 100644 --- a/build-aux/syntax-check.mk +++ b/build-aux/syntax-check.mk @@ -130,17 +130,6 @@ syntax-check: $(local-check) _test_script_regex = \<test-lib\.sh\> -# Most developers don't run 'make distcheck'. We want the official -# dist to be secure, but don't want to penalize other developers -# using a distro that has not yet picked up the automake fix. -# FIXME remove this ifeq (making the syntax check unconditional) -# once fixed automake (1.11.6 or 1.12.2+) is more common. -ifeq ($(filter dist%, $(MAKECMDGOALS)), ) -local-checks-to-skip += sc_vulnerable_makefile_CVE-2012-3386 -else -distdir: sc_vulnerable_makefile_CVE-2012-3386.z -endif - # Files that should never cause syntax check failures. VC_LIST_ALWAYS_EXCLUDE_REGEX = \ (^(docs/(news(-[0-9]*)?\.html\.in|.*\.patch))|\.(po|fig|gif|ico|png))$$ @@ -1957,25 +1946,6 @@ sc_prohibit_path_max_allocation: halt='Avoid stack allocations of size PATH_MAX' \ $(_sc_search_regexp) -sc_vulnerable_makefile_CVE-2009-4029: - @prohibit='perm -777 -exec chmod a\+rwx|chmod 777 \$$\(distdir\)' \ - in_files='(^|/)Makefile\.in$$' \ - halt=$$(printf '%s\n' \ - 'the above files are vulnerable; beware of running' \ - ' "make dist*" rules, and upgrade to fixed automake' \ - ' see https://bugzilla.redhat.com/show_bug.cgi?id=542609 for details') \ - $(_sc_search_regexp) - -sc_vulnerable_makefile_CVE-2012-3386: - @prohibit='chmod a\+w \$$\(distdir\)' \ - in_files='(^|/)Makefile\.in$$' \ - halt=$$(printf '%s\n' \ - 'the above files are vulnerable; beware of running' \ - ' "make distcheck", and upgrade to fixed automake' \ - ' see https://bugzilla.redhat.com/show_bug.cgi?id=CVE-2012-3386 for details') \ - $(_sc_search_regexp) - - ifneq ($(_gl-Makefile),) syntax-check: spacing-check test-wrap-argv \ prohibit-duplicate-header mock-noinline group-qemu-caps \ -- 2.24.1

$ date +%Y 2020 Signed-off-by: Ján Tomko <jtomko@redhat.com> --- build-aux/syntax-check.mk | 8 -------- 1 file changed, 8 deletions(-) diff --git a/build-aux/syntax-check.mk b/build-aux/syntax-check.mk index 52a6062ad5..23d2bf8b34 100644 --- a/build-aux/syntax-check.mk +++ b/build-aux/syntax-check.mk @@ -1655,14 +1655,6 @@ sc_GFDL_version: halt='GFDL vN, N!=3' \ $(_sc_search_regexp) -cvs_keywords = \ - Author|Date|Header|Id|Name|Locker|Log|RCSfile|Revision|Source|State - -sc_prohibit_cvs_keyword: - @prohibit='\$$($(cvs_keywords))\$$' \ - halt='do not use CVS keyword expansion' \ - $(_sc_search_regexp) - # This Perl code is slightly obfuscated. Not only is each "$" doubled # because it's in a Makefile, but the $$c's are comments; we cannot # use "#" due to the way the script ends up concatenated onto one line. -- 2.24.1

NEWS was replaced by docs/news.html, so the pre-requisite for this rule is not fulfilled. Also, PREV_VERSION_REGEXP does not seem to be defined anywhere. Signed-off-by: Ján Tomko <jtomko@redhat.com> --- build-aux/syntax-check.mk | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/build-aux/syntax-check.mk b/build-aux/syntax-check.mk index 23d2bf8b34..2c1ec877b1 100644 --- a/build-aux/syntax-check.mk +++ b/build-aux/syntax-check.mk @@ -1795,20 +1795,6 @@ sc_const_long_option: halt='add "const" to the above declarations' \ $(_sc_search_regexp) -NEWS_hash = \ - $$($(SED) -n '/^\*.* $(PREV_VERSION_REGEXP) ([0-9-]*)/,$$p' \ - $(srcdir)/NEWS \ - | perl -0777 -pe \ - 's/^Copyright.+?Free\sSoftware\sFoundation,\sInc\.\n//ms' \ - | md5sum - \ - | $(SED) 's/ .*//') - -# Update the hash stored above. Do this after each release and -# for any corrections to old entries. -update-NEWS-hash: NEWS - perl -pi -e 's/^(old_NEWS_hash[ \t]+:?=[ \t]+).*/$${1}'"$(NEWS_hash)/" \ - $(srcdir)/syntax-check.mk - # Ensure that we use only the standard $(VAR) notation, # not @...@ in Makefile.am, now that we can rely on automake # to emit a definition for each substituted variable. -- 2.24.1

Both xen/xend_internal and bootstrap.conf have been deleted from git. Signed-off-by: Ján Tomko <jtomko@redhat.com> --- build-aux/syntax-check.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build-aux/syntax-check.mk b/build-aux/syntax-check.mk index 2c1ec877b1..3c1f46cb98 100644 --- a/build-aux/syntax-check.mk +++ b/build-aux/syntax-check.mk @@ -1969,7 +1969,7 @@ group-qemu-caps: # List all syntax-check exemptions: exclude_file_name_regexp--sc_avoid_strcase = ^tools/vsh\.h$$ -_src1=libvirt-stream|qemu/qemu_monitor|util/vir(command|file|fdstream)|xen/xend_internal|rpc/virnetsocket|lxc/lxc_controller|locking/lock_daemon|logging/log_daemon +_src1=libvirt-stream|qemu/qemu_monitor|util/vir(command|file|fdstream)|rpc/virnetsocket|lxc/lxc_controller|locking/lock_daemon|logging/log_daemon _test1=shunloadtest|virnettlscontexttest|virnettlssessiontest|vircgroupmock|commandhelper exclude_file_name_regexp--sc_avoid_write = \ ^(src/($(_src1))|tools/virsh-console|tests/($(_test1)))\.c$$ @@ -2008,7 +2008,7 @@ exclude_file_name_regexp--sc_prohibit_access_xok = \ ^(src/util/virutil\.c)$$ exclude_file_name_regexp--sc_prohibit_asprintf = \ - ^(build-aux/syntax-check\.mk|bootstrap.conf$$|examples/|src/util/virstring\.[ch]$$|tests/vircgroupmock\.c|tools/virt-login-shell\.c|tools/nss/libvirt_nss\.c$$) + ^(build-aux/syntax-check\.mk|examples/|src/util/virstring\.[ch]$$|tests/vircgroupmock\.c|tools/virt-login-shell\.c|tools/nss/libvirt_nss\.c$$) exclude_file_name_regexp--sc_prohibit_strdup = \ ^(docs/|examples/|src/util/virstring\.c|tests/vir(netserverclient|cgroup)mock.c|tests/commandhelper\.c|tools/nss/libvirt_nss_(leases|macs)\.c$$) -- 2.24.1

We no longer implement a wrapper over strdup - g_strdup is preferred. The use of strncpy was removed in: commit 7d70a63b947e9a654a4e3fffa0ffa355f5549ec7 util: Improve virStrncpy() implementation Signed-off-by: Ján Tomko <jtomko@redhat.com> --- build-aux/syntax-check.mk | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/build-aux/syntax-check.mk b/build-aux/syntax-check.mk index 3c1f46cb98..7cd47e1331 100644 --- a/build-aux/syntax-check.mk +++ b/build-aux/syntax-check.mk @@ -2008,10 +2008,10 @@ exclude_file_name_regexp--sc_prohibit_access_xok = \ ^(src/util/virutil\.c)$$ exclude_file_name_regexp--sc_prohibit_asprintf = \ - ^(build-aux/syntax-check\.mk|examples/|src/util/virstring\.[ch]$$|tests/vircgroupmock\.c|tools/virt-login-shell\.c|tools/nss/libvirt_nss\.c$$) + ^(build-aux/syntax-check\.mk|examples/|tests/vircgroupmock\.c|tools/virt-login-shell\.c|tools/nss/libvirt_nss\.c$$) exclude_file_name_regexp--sc_prohibit_strdup = \ - ^(docs/|examples/|src/util/virstring\.c|tests/vir(netserverclient|cgroup)mock.c|tests/commandhelper\.c|tools/nss/libvirt_nss_(leases|macs)\.c$$) + ^(docs/|examples/|tests/virnetserverclientmock.c|tests/commandhelper.c|tools/nss/libvirt_nss_(leases|macs)\.c$$) exclude_file_name_regexp--sc_prohibit_close = \ (\.p[yl]$$|\.spec\.in$$|^docs/|^(src/util/vir(file|event)\.c|src/libvirt-stream\.c|tests/(vir.+mock\.c|commandhelper\.c|qemusecuritymock\.c)|tools/nss/libvirt_nss_(leases|macs)\.c)$$) @@ -2054,8 +2054,6 @@ exclude_file_name_regexp--sc_prohibit_setuid = ^src/util/virutil\.c|tools/virt-l exclude_file_name_regexp--sc_prohibit_snprintf = \ ^(build-aux/syntax-check\.mk|docs/hacking\.html\.in|tools/virt-login-shell\.c)$$ -exclude_file_name_regexp--sc_prohibit_strncpy = ^src/util/virstring\.c$$ - exclude_file_name_regexp--sc_prohibit_strtol = ^examples/.*$$ exclude_file_name_regexp--sc_prohibit_xmlGetProp = ^src/util/virxml\.c$$ -- 2.24.1

This exception is no longer useful since README is just a symlink to README.md, which is a subject to this check already. Signed-off-by: Ján Tomko <jtomko@redhat.com> --- build-aux/syntax-check.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-aux/syntax-check.mk b/build-aux/syntax-check.mk index 7cd47e1331..1410d1242f 100644 --- a/build-aux/syntax-check.mk +++ b/build-aux/syntax-check.mk @@ -2100,7 +2100,7 @@ exclude_file_name_regexp--sc_prohibit_mixed_case_abbreviations = \ ^src/(vbox/vbox_CAPI.*.h|esx/esx_vi.(c|h)|esx/esx_storage_backend_iscsi.c)$$ exclude_file_name_regexp--sc_prohibit_empty_first_line = \ - ^(README|src/esx/README|tests/(vmwarever|virhostcpu)data/.*)$$ + ^(src/esx/README|tests/(vmwarever|virhostcpu)data/.*)$$ exclude_file_name_regexp--sc_prohibit_useless_translation = \ ^tests/virpolkittest.c -- 2.24.1

Do not look for exception patterns in ${srcdir}./x-$@ nor the VC_LIST_EXCEPT_DEFAULT variable. This also removes the default exception for ChangeLog. Signed-off-by: Ján Tomko <jtomko@redhat.com> --- build-aux/syntax-check.mk | 2 -- 1 file changed, 2 deletions(-) diff --git a/build-aux/syntax-check.mk b/build-aux/syntax-check.mk index 1410d1242f..70bf8c9d89 100644 --- a/build-aux/syntax-check.mk +++ b/build-aux/syntax-check.mk @@ -69,8 +69,6 @@ _sc_excl = \ $(or $(exclude_file_name_regexp--$@),^$$) VC_LIST_EXCEPT = \ $(VC_LIST) | $(SED) 's|^$(_dot_escaped_srcdir)/||' \ - | if test -f $(srcdir)/.x-$@; then $(GREP) -vEf $(srcdir)/.x-$@; \ - else $(GREP) -Ev -e "$${VC_LIST_EXCEPT_DEFAULT-ChangeLog}"; fi \ | $(GREP) -Ev -e '($(VC_LIST_ALWAYS_EXCLUDE_REGEX)|$(_sc_excl))' \ $(_prepend_srcdir_prefix) -- 2.24.1

On 2/11/20 2:37 AM, Ján Tomko wrote:
And drop some legacy stuff, since I already had to open the file.
Ján Tomko (9): syntax-check: do not enforce ChangeLog syntax syntax-check: fix sc-prohibit-cross-inclusion syntax-check: drop vulnerable Makefile checks syntax-check: drop CVS keyword expansion check syntax-check: drop update-NEWS-hash syntax-check: exclude: remove deleted files syntax-check: exclude: remove virstring syntax-check: remove README syntax-check: remove some exception mechanisms
build-aux/syntax-check.mk | 73 +++------------------------------------ 1 file changed, 5 insertions(+), 68 deletions(-)
Reviewed-by: Michal Privoznik <mprivozn@redhat.com> Michal
participants (2)
-
Ján Tomko
-
Michal Privoznik