syntax-check: Enforce sc_prohibit_backslash_alignment everywhere

Basically all files in the repository are already passing the
check, except for syntax-check.mk itself. Fix that, and stop
limiting the files on which the test is performed.

These changes have been generated by running

  $ sed -Ei 's/[ '$'\t'']+\\$/ \\/g' $(git grep -El '[ '$'\t'']+\\$')

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Andrea Bolognani 2022-05-23 17:01:00 +02:00
parent 6545173b69
commit 7f403bc251
2 changed files with 207 additions and 211 deletions

View File

@ -863,7 +863,6 @@ sc_prohibit_author:
# or tabs (at least one of them) right before the trailing backslash # or tabs (at least one of them) right before the trailing backslash
sc_prohibit_backslash_alignment: sc_prohibit_backslash_alignment:
@prohibit='( | )\\$$' \ @prohibit='( | )\\$$' \
in_vc_files='*\.([chx]|am|mk)$$' \
halt='Do not attempt to right-align backslashes' \ halt='Do not attempt to right-align backslashes' \
$(_sc_search_regexp) $(_sc_search_regexp)
@ -900,28 +899,28 @@ sc_prohibit_dirent_d_type:
$(_sc_search_regexp) $(_sc_search_regexp)
sc_cast_of_argument_to_free: sc_cast_of_argument_to_free:
@prohibit='\<free *\( *\(' halt="don't cast free argument" \ @prohibit='\<free *\( *\(' halt="don't cast free argument" \
$(_sc_search_regexp) $(_sc_search_regexp)
sc_cast_of_x_alloc_return_value: sc_cast_of_x_alloc_return_value:
@prohibit='\*\) *x(m|c|re)alloc\>' \ @prohibit='\*\) *x(m|c|re)alloc\>' \
halt="don't cast x*alloc return value" \ halt="don't cast x*alloc return value" \
$(_sc_search_regexp) $(_sc_search_regexp)
# Use STREQ rather than comparing strcmp == 0, or != 0. # Use STREQ rather than comparing strcmp == 0, or != 0.
sp_ = strcmp *\(.+\) sp_ = strcmp *\(.+\)
sc_prohibit_strcmp: sc_prohibit_strcmp:
@prohibit='! *strcmp *\(|\<$(sp_) *[!=]=|[!=]= *$(sp_)' \ @prohibit='! *strcmp *\(|\<$(sp_) *[!=]=|[!=]= *$(sp_)' \
exclude='# *define STRN?EQ\(' \ exclude='# *define STRN?EQ\(' \
halt='replace strcmp calls above with STREQ/STRNEQ' \ halt='replace strcmp calls above with STREQ/STRNEQ' \
$(_sc_search_regexp) $(_sc_search_regexp)
# Really. You don't want to use this function. # Really. You don't want to use this function.
# It may fail to NUL-terminate the destination, # It may fail to NUL-terminate the destination,
# and always NUL-pads out to the specified length. # and always NUL-pads out to the specified length.
sc_prohibit_strncpy: sc_prohibit_strncpy:
@prohibit='\<strncpy *\(' \ @prohibit='\<strncpy *\(' \
halt='do not use strncpy, period' \ halt='do not use strncpy, period' \
$(_sc_search_regexp) $(_sc_search_regexp)
# Pass EXIT_*, not number, to usage, exit, and error (when exiting) # Pass EXIT_*, not number, to usage, exit, and error (when exiting)
@ -935,34 +934,34 @@ sc_prohibit_strncpy:
# | xargs --no-run-if-empty \ # | xargs --no-run-if-empty \
# perl -pi -e 's/(^|[^.])\b(exit ?)\(0\)/$1$2(EXIT_SUCCESS)/' # perl -pi -e 's/(^|[^.])\b(exit ?)\(0\)/$1$2(EXIT_SUCCESS)/'
sc_prohibit_magic_number_exit: sc_prohibit_magic_number_exit:
@prohibit='(^|[^.])\<(usage|exit|error) ?\(-?[0-9]+[,)]' \ @prohibit='(^|[^.])\<(usage|exit|error) ?\(-?[0-9]+[,)]' \
exclude='exit \(77\)|error ?\(((0|77),|[^,]*)' \ exclude='exit \(77\)|error ?\(((0|77),|[^,]*)' \
halt='use EXIT_* values rather than magic number' \ halt='use EXIT_* values rather than magic number' \
$(_sc_search_regexp) $(_sc_search_regexp)
# "FATAL:" should be fully upper-cased in error messages # "FATAL:" should be fully upper-cased in error messages
# "WARNING:" should be fully upper-cased, or fully lower-cased # "WARNING:" should be fully upper-cased, or fully lower-cased
sc_error_message_warn_fatal: sc_error_message_warn_fatal:
@$(VC_LIST_EXCEPT) \ @$(VC_LIST_EXCEPT) \
| xargs $(GREP) -nEA2 '[^rp]error *\(' /dev/null \ | xargs $(GREP) -nEA2 '[^rp]error *\(' /dev/null \
| $(GREP) -E '"Warning|"Fatal|"fatal' \ | $(GREP) -E '"Warning|"Fatal|"fatal' \
&& { echo 'use FATAL, WARNING or warning' 1>&2; \ && { echo 'use FATAL, WARNING or warning' 1>&2; \
exit 1; } \ exit 1; } \
|| : || :
# Error messages should not end with a period # Error messages should not end with a period
sc_error_message_period: sc_error_message_period:
@$(VC_LIST_EXCEPT) \ @$(VC_LIST_EXCEPT) \
| xargs $(GREP) -nEA2 '[^rp]error *\(' /dev/null \ | xargs $(GREP) -nEA2 '[^rp]error *\(' /dev/null \
| $(GREP) -E '[^."]\."' \ | $(GREP) -E '[^."]\."' \
&& { echo 'found error message ending in period' 1>&2; \ && { echo 'found error message ending in period' 1>&2; \
exit 1; } \ exit 1; } \
|| : || :
# Don't use cpp tests of this symbol. All code assumes config.h is included. # Don't use cpp tests of this symbol. All code assumes config.h is included.
sc_prohibit_have_config_h: sc_prohibit_have_config_h:
@prohibit='^# *if.*HAVE''_CONFIG_H' \ @prohibit='^# *if.*HAVE''_CONFIG_H' \
halt='found use of HAVE''_CONFIG_H; remove' \ halt='found use of HAVE''_CONFIG_H; remove' \
$(_sc_search_regexp) $(_sc_search_regexp)
# Nearly all .c files must include <config.h>. However, we also permit this # Nearly all .c files must include <config.h>. However, we also permit this
@ -970,49 +969,49 @@ sc_prohibit_have_config_h:
# config_h_header must be suitable for grep -E. # config_h_header must be suitable for grep -E.
config_h_header ?= <config\.h> config_h_header ?= <config\.h>
sc_require_config_h: sc_require_config_h:
@require='^# *include $(config_h_header)' \ @require='^# *include $(config_h_header)' \
in_vc_files='\.c$$' \ in_vc_files='\.c$$' \
halt='the above files do not include <config.h>' \ halt='the above files do not include <config.h>' \
$(_sc_search_regexp) $(_sc_search_regexp)
# Print each file name for which the first #include does not match # Print each file name for which the first #include does not match
# $(config_h_header). Like grep -m 1, this only looks at the first match. # $(config_h_header). Like grep -m 1, this only looks at the first match.
perl_config_h_first_ = \ perl_config_h_first_ = \
-e 'BEGIN {$$ret = 0}' \ -e 'BEGIN {$$ret = 0}' \
-e 'if (/^\# *include\b/) {' \ -e 'if (/^\# *include\b/) {' \
-e ' if (not m{^\# *include $(config_h_header)}) {' \ -e ' if (not m{^\# *include $(config_h_header)}) {' \
-e ' print "$$ARGV\n";' \ -e ' print "$$ARGV\n";' \
-e ' $$ret = 1;' \ -e ' $$ret = 1;' \
-e ' }' \ -e ' }' \
-e ' \# Move on to next file after first include' \ -e ' \# Move on to next file after first include' \
-e ' close ARGV;' \ -e ' close ARGV;' \
-e '}' \ -e '}' \
-e 'END {exit $$ret}' -e 'END {exit $$ret}'
# You must include <config.h> before including any other header file. # You must include <config.h> before including any other header file.
# This can possibly be via a package-specific header, if given by syntax-check.mk. # This can possibly be via a package-specific header, if given by syntax-check.mk.
sc_require_config_h_first: sc_require_config_h_first:
@if $(VC_LIST_EXCEPT) | $(GREP) '\.c$$' > /dev/null; then \ @if $(VC_LIST_EXCEPT) | $(GREP) '\.c$$' > /dev/null; then \
files=$$($(VC_LIST_EXCEPT) | $(GREP) '\.c$$') && \ files=$$($(VC_LIST_EXCEPT) | $(GREP) '\.c$$') && \
perl -n $(perl_config_h_first_) $$files || \ perl -n $(perl_config_h_first_) $$files || \
{ echo 'the above files include some other header' \ { echo 'the above files include some other header' \
'before <config.h>' 1>&2; exit 1; } || :; \ 'before <config.h>' 1>&2; exit 1; } || :; \
else :; \ else :; \
fi fi
# To use this "command" macro, you must first define two shell variables: # To use this "command" macro, you must first define two shell variables:
# h: the header name, with no enclosing <> or "" # h: the header name, with no enclosing <> or ""
# re: a regular expression that matches IFF something provided by $h is used. # re: a regular expression that matches IFF something provided by $h is used.
define _sc_header_without_use define _sc_header_without_use
dummy=; : so we do not need a semicolon before each use; \ dummy=; : so we do not need a semicolon before each use; \
h_esc=`echo '[<"]'"$$h"'[">]'|$(SED) 's/\./\\\\./g'`; \ h_esc=`echo '[<"]'"$$h"'[">]'|$(SED) 's/\./\\\\./g'`; \
if $(VC_LIST_EXCEPT) | $(GREP) '\.c$$' > /dev/null; then \ if $(VC_LIST_EXCEPT) | $(GREP) '\.c$$' > /dev/null; then \
files=$$($(GREP) -l '^# *include '"$$h_esc" \ files=$$($(GREP) -l '^# *include '"$$h_esc" \
$$($(VC_LIST_EXCEPT) | $(GREP) '\.c$$')) && \ $$($(VC_LIST_EXCEPT) | $(GREP) '\.c$$')) && \
$(GREP) -LE "$$re" $$files | $(GREP) . && \ $(GREP) -LE "$$re" $$files | $(GREP) . && \
{ echo "the above files include $$h but don't use it" \ { echo "the above files include $$h but don't use it" \
1>&2; exit 1; } || :; \ 1>&2; exit 1; } || :; \
else :; \ else :; \
fi fi
endef endef
@ -1034,41 +1033,41 @@ _sig_functions = \
sigrelse sigset sigsuspend sigtimedwait sigwait sigwaitinfo sigrelse sigset sigsuspend sigtimedwait sigwait sigwaitinfo
_sig_function_re = $(subst $(_sp),|,$(strip $(_sig_functions))) _sig_function_re = $(subst $(_sp),|,$(strip $(_sig_functions)))
# The following were extracted from "man signal.h" manually. # The following were extracted from "man signal.h" manually.
_sig_types_and_consts = \ _sig_types_and_consts = \
MINSIGSTKSZ SA_NOCLDSTOP SA_NOCLDWAIT SA_NODEFER SA_ONSTACK \ MINSIGSTKSZ SA_NOCLDSTOP SA_NOCLDWAIT SA_NODEFER SA_ONSTACK \
SA_RESETHAND SA_RESTART SA_SIGINFO SIGEV_NONE SIGEV_SIGNAL \ SA_RESETHAND SA_RESTART SA_SIGINFO SIGEV_NONE SIGEV_SIGNAL \
SIGEV_THREAD SIGSTKSZ SIG_BLOCK SIG_SETMASK SIG_UNBLOCK SS_DISABLE \ SIGEV_THREAD SIGSTKSZ SIG_BLOCK SIG_SETMASK SIG_UNBLOCK SS_DISABLE \
SS_ONSTACK mcontext_t pid_t sig_atomic_t sigevent siginfo_t sigset_t \ SS_ONSTACK mcontext_t pid_t sig_atomic_t sigevent siginfo_t sigset_t \
sigstack sigval stack_t ucontext_t sigstack sigval stack_t ucontext_t
# generated via this: # generated via this:
# perl -lne '/^#ifdef (SIG\w+)/ and print $1' lib/sig2str.c|sort -u|fmt -70 # perl -lne '/^#ifdef (SIG\w+)/ and print $1' lib/sig2str.c|sort -u|fmt -70
_sig_names = \ _sig_names = \
SIGABRT SIGALRM SIGALRM1 SIGBUS SIGCANCEL SIGCHLD SIGCLD SIGCONT \ SIGABRT SIGALRM SIGALRM1 SIGBUS SIGCANCEL SIGCHLD SIGCLD SIGCONT \
SIGDANGER SIGDIL SIGEMT SIGFPE SIGFREEZE SIGGRANT SIGHUP SIGILL \ SIGDANGER SIGDIL SIGEMT SIGFPE SIGFREEZE SIGGRANT SIGHUP SIGILL \
SIGINFO SIGINT SIGIO SIGIOT SIGKAP SIGKILL SIGKILLTHR SIGLOST SIGLWP \ SIGINFO SIGINT SIGIO SIGIOT SIGKAP SIGKILL SIGKILLTHR SIGLOST SIGLWP \
SIGMIGRATE SIGMSG SIGPHONE SIGPIPE SIGPOLL SIGPRE SIGPROF SIGPWR \ SIGMIGRATE SIGMSG SIGPHONE SIGPIPE SIGPOLL SIGPRE SIGPROF SIGPWR \
SIGQUIT SIGRETRACT SIGSAK SIGSEGV SIGSOUND SIGSTKFLT SIGSTOP SIGSYS \ SIGQUIT SIGRETRACT SIGSAK SIGSEGV SIGSOUND SIGSTKFLT SIGSTOP SIGSYS \
SIGTERM SIGTHAW SIGTRAP SIGTSTP SIGTTIN SIGTTOU SIGURG SIGUSR1 \ SIGTERM SIGTHAW SIGTRAP SIGTSTP SIGTTIN SIGTTOU SIGURG SIGUSR1 \
SIGUSR2 SIGVIRT SIGVTALRM SIGWAITING SIGWINCH SIGWIND SIGWINDOW \ SIGUSR2 SIGVIRT SIGVTALRM SIGWAITING SIGWINCH SIGWIND SIGWINDOW \
SIGXCPU SIGXFSZ SIGXCPU SIGXFSZ
_sig_syms_re = $(subst $(_sp),|,$(strip $(_sig_names) $(_sig_types_and_consts))) _sig_syms_re = $(subst $(_sp),|,$(strip $(_sig_names) $(_sig_types_and_consts)))
# Prohibit the inclusion of signal.h without an actual use. # Prohibit the inclusion of signal.h without an actual use.
sc_prohibit_signal_without_use: sc_prohibit_signal_without_use:
@h='signal.h' \ @h='signal.h' \
re='\<($(_sig_function_re)) *\(|\<($(_sig_syms_re))\>' \ re='\<($(_sig_function_re)) *\(|\<($(_sig_syms_re))\>' \
$(_sc_header_without_use) $(_sc_header_without_use)
# Don't include stdio--.h unless you use one of its functions. # Don't include stdio--.h unless you use one of its functions.
sc_prohibit_stdio--_without_use: sc_prohibit_stdio--_without_use:
@h='stdio--.h' re='\<((f(re)?|p)open|tmpfile) *\(' \ @h='stdio--.h' re='\<((f(re)?|p)open|tmpfile) *\(' \
$(_sc_header_without_use) $(_sc_header_without_use)
_stddef_syms_re = NULL|offsetof|ptrdiff_t|size_t|wchar_t _stddef_syms_re = NULL|offsetof|ptrdiff_t|size_t|wchar_t
# Prohibit the inclusion of stddef.h without an actual use. # Prohibit the inclusion of stddef.h without an actual use.
sc_prohibit_stddef_without_use: sc_prohibit_stddef_without_use:
@h='stddef.h' \ @h='stddef.h' \
re='\<($(_stddef_syms_re))\>' \ re='\<($(_stddef_syms_re))\>' \
$(_sc_header_without_use) $(_sc_header_without_use)
_de1 = dirfd|(close|(fd)?open|read|rewind|seek|tell)dir(64)?(_r)? _de1 = dirfd|(close|(fd)?open|read|rewind|seek|tell)dir(64)?(_r)?
@ -1077,14 +1076,14 @@ _de3 = MAXNAMLEN|DIR|ino_t|d_ino|d_fileno|d_namlen
_dirent_syms_re = $(_de1)|$(_de2)|$(_de3) _dirent_syms_re = $(_de1)|$(_de2)|$(_de3)
# Prohibit the inclusion of dirent.h without an actual use. # Prohibit the inclusion of dirent.h without an actual use.
sc_prohibit_dirent_without_use: sc_prohibit_dirent_without_use:
@h='dirent.h' \ @h='dirent.h' \
re='\<($(_dirent_syms_re))\>' \ re='\<($(_dirent_syms_re))\>' \
$(_sc_header_without_use) $(_sc_header_without_use)
sc_trailing_blank: sc_trailing_blank:
@prohibit='[ ]$$' \ @prohibit='[ ]$$' \
halt='found trailing blank(s)' \ halt='found trailing blank(s)' \
exclude='^Binary file .* matches$$' \ exclude='^Binary file .* matches$$' \
$(_sc_search_regexp) $(_sc_search_regexp)
@ -1096,20 +1095,20 @@ _gl_translatable_diag_func_re ?= error
# This won't find any for which error's format string is on a separate line. # This won't find any for which error's format string is on a separate line.
sc_unmarked_diagnostics: sc_unmarked_diagnostics:
@prohibit='\<$(_gl_translatable_diag_func_re) *\([^"]*"[^"]*[a-z]{3}' \ @prohibit='\<$(_gl_translatable_diag_func_re) *\([^"]*"[^"]*[a-z]{3}' \
exclude='(_|ngettext ?)\(' \ exclude='(_|ngettext ?)\(' \
halt='found unmarked diagnostic(s)' \ halt='found unmarked diagnostic(s)' \
$(_sc_search_regexp) $(_sc_search_regexp)
sc_prohibit_defined_have_decl_tests: sc_prohibit_defined_have_decl_tests:
@prohibit='(#[ ]*ifn?def|\<defined)\>[ (]+WITH_DECL_' \ @prohibit='(#[ ]*ifn?def|\<defined)\>[ (]+WITH_DECL_' \
halt='WITH_DECL macros are always defined' \ halt='WITH_DECL macros are always defined' \
$(_sc_search_regexp) $(_sc_search_regexp)
# Prohibit checked in backup files. # Prohibit checked in backup files.
sc_prohibit_backup_files: sc_prohibit_backup_files:
@$(VC_LIST_EXCEPT) | $(GREP) '~$$' && \ @$(VC_LIST_EXCEPT) | $(GREP) '~$$' && \
{ echo 'found version controlled backup file' 1>&2; \ { echo 'found version controlled backup file' 1>&2; \
exit 1; } || : exit 1; } || :
# This Perl code is slightly obfuscated. Not only is each "$" doubled # This Perl code is slightly obfuscated. Not only is each "$" doubled
@ -1135,36 +1134,36 @@ sc_prohibit_backup_files:
# Use this if you want to remove trailing empty lines from selected files: # Use this if you want to remove trailing empty lines from selected files:
# perl -pi -0777 -e 's/\n\n+$/\n/' files... # perl -pi -0777 -e 's/\n\n+$/\n/' files...
# #
require_exactly_one_NL_at_EOF_ = \ require_exactly_one_NL_at_EOF_ = \
foreach my $$f (@ARGV) \ foreach my $$f (@ARGV) \
{ \ { \
open F, "<", $$f or (warn "failed to open $$f: $$!\n"), next; \ open F, "<", $$f or (warn "failed to open $$f: $$!\n"), next; \
my $$p = sysseek (F, -2, 2); \ my $$p = sysseek (F, -2, 2); \
my $$c = "seek failure probably means file has < 2 bytes; ignore"; \ my $$c = "seek failure probably means file has < 2 bytes; ignore"; \
my $$last_two_bytes; \ my $$last_two_bytes; \
defined $$p and $$p = sysread F, $$last_two_bytes, 2; \ defined $$p and $$p = sysread F, $$last_two_bytes, 2; \
close F; \ close F; \
$$c = "ignore read failure"; \ $$c = "ignore read failure"; \
$$p && ($$last_two_bytes eq "\n\n" \ $$p && ($$last_two_bytes eq "\n\n" \
|| substr ($$last_two_bytes,1) ne "\n") \ || substr ($$last_two_bytes,1) ne "\n") \
and (print $$f), $$fail=1; \ and (print $$f), $$fail=1; \
} \ } \
END { exit defined $$fail } END { exit defined $$fail }
sc_prohibit_empty_lines_at_EOF: sc_prohibit_empty_lines_at_EOF:
@$(VC_LIST_EXCEPT) \ @$(VC_LIST_EXCEPT) \
| xargs perl -le '$(require_exactly_one_NL_at_EOF_)' \ | xargs perl -le '$(require_exactly_one_NL_at_EOF_)' \
|| { echo 'empty line(s) or no newline at EOF' 1>&2; \ || { echo 'empty line(s) or no newline at EOF' 1>&2; \
exit 1; } \ exit 1; } \
|| : || :
# Perl block to convert a match to FILE_NAME:LINENO:TEST, # Perl block to convert a match to FILE_NAME:LINENO:TEST,
# that is shared by two definitions below. # that is shared by two definitions below.
perl_filename_lineno_text_ = \ perl_filename_lineno_text_ = \
-e ' {' \ -e ' {' \
-e ' $$n = ($$` =~ tr/\n/\n/ + 1);' \ -e ' $$n = ($$` =~ tr/\n/\n/ + 1);' \
-e ' ($$v = $$&) =~ s/\n/\\n/g;' \ -e ' ($$v = $$&) =~ s/\n/\\n/g;' \
-e ' print "$$ARGV:$$n:$$v\n";' \ -e ' print "$$ARGV:$$n:$$v\n";' \
-e ' }' -e ' }'
prohibit_doubled_words_ = \ prohibit_doubled_words_ = \
@ -1174,8 +1173,8 @@ prohibit_doubled_word_expanded_ = \
$(join $(prohibit_doubled_words_),$(addprefix \s+,$(prohibit_doubled_words_))) $(join $(prohibit_doubled_words_),$(addprefix \s+,$(prohibit_doubled_words_)))
prohibit_doubled_word_RE_ ?= \ prohibit_doubled_word_RE_ ?= \
/\b(?:$(subst $(_sp),|,$(prohibit_doubled_word_expanded_)))\b/gims /\b(?:$(subst $(_sp),|,$(prohibit_doubled_word_expanded_)))\b/gims
prohibit_doubled_word_ = \ prohibit_doubled_word_ = \
-e 'while ($(prohibit_doubled_word_RE_))' \ -e 'while ($(prohibit_doubled_word_RE_))' \
$(perl_filename_lineno_text_) $(perl_filename_lineno_text_)
# Define this to a regular expression that matches # Define this to a regular expression that matches
@ -1184,19 +1183,19 @@ prohibit_doubled_word_ = \
ignore_doubled_word_match_RE_ ?= ^$$ ignore_doubled_word_match_RE_ ?= ^$$
sc_prohibit_doubled_word: sc_prohibit_doubled_word:
@$(VC_LIST_EXCEPT) \ @$(VC_LIST_EXCEPT) \
| xargs perl -n -0777 $(prohibit_doubled_word_) \ | xargs perl -n -0777 $(prohibit_doubled_word_) \
| $(GREP) -vE '$(ignore_doubled_word_match_RE_)' \ | $(GREP) -vE '$(ignore_doubled_word_match_RE_)' \
| $(GREP) . \ | $(GREP) . \
&& { echo 'doubled words' 1>&2; exit 1; } \ && { echo 'doubled words' 1>&2; exit 1; } \
|| : || :
# Except for shell files and for loops, double semicolon is probably a mistake # Except for shell files and for loops, double semicolon is probably a mistake
sc_prohibit_double_semicolon: sc_prohibit_double_semicolon:
@prohibit='; *;[ {} \]*(/[/*]|$$)' \ @prohibit='; *;[ {} \]*(/[/*]|$$)' \
in_vc_files='\.[chly]$$' \ in_vc_files='\.[chly]$$' \
exclude='\bfor *\(.*\)' \ exclude='\bfor *\(.*\)' \
halt="Double semicolon detected" \ halt="Double semicolon detected" \
$(_sc_search_regexp) $(_sc_search_regexp)
_ptm1 = use "test C1 && test C2", not "test C1 -''a C2" _ptm1 = use "test C1 && test C2", not "test C1 -''a C2"
@ -1204,29 +1203,29 @@ _ptm2 = use "test C1 || test C2", not "test C1 -''o C2"
# Using test's -a and -o operators is not portable. # Using test's -a and -o operators is not portable.
# We prefer test over [, since the latter is spelled [[ in configure.ac. # We prefer test over [, since the latter is spelled [[ in configure.ac.
sc_prohibit_test_minus_ao: sc_prohibit_test_minus_ao:
@prohibit='(\<test| \[+) .+ -[ao] ' \ @prohibit='(\<test| \[+) .+ -[ao] ' \
halt='$(_ptm1); $(_ptm2)' \ halt='$(_ptm1); $(_ptm2)' \
$(_sc_search_regexp) $(_sc_search_regexp)
# Avoid a test bashism. # Avoid a test bashism.
sc_prohibit_test_double_equal: sc_prohibit_test_double_equal:
@prohibit='(\<test| \[+) .+ == ' \ @prohibit='(\<test| \[+) .+ == ' \
containing='#! */bin/[a-z]*sh' \ containing='#! */bin/[a-z]*sh' \
halt='use "test x = x", not "test x =''= x"' \ halt='use "test x = x", not "test x =''= x"' \
$(_sc_search_regexp) $(_sc_search_regexp)
# Warn about "c0nst struct Foo const foo[]", # Warn about "c0nst struct Foo const foo[]",
# but not about "char const *const foo" or "#define const const". # but not about "char const *const foo" or "#define const const".
sc_redundant_const: sc_redundant_const:
@prohibit='\bconst\b[[:space:][:alnum:]]{2,}\bconst\b' \ @prohibit='\bconst\b[[:space:][:alnum:]]{2,}\bconst\b' \
halt='redundant "const" in declarations' \ halt='redundant "const" in declarations' \
$(_sc_search_regexp) $(_sc_search_regexp)
sc_const_long_option: sc_const_long_option:
@prohibit='^ *static.*struct option ' \ @prohibit='^ *static.*struct option ' \
exclude='const struct option|struct option const' \ exclude='const struct option|struct option const' \
halt='add "const" to the above declarations' \ halt='add "const" to the above declarations' \
$(_sc_search_regexp) $(_sc_search_regexp)
fix_po_file_diag = \ fix_po_file_diag = \
@ -1234,18 +1233,18 @@ fix_po_file_diag = \
apply the above patch\n' apply the above patch\n'
# Generate a list of files in which to search for translatable strings. # Generate a list of files in which to search for translatable strings.
perl_translatable_files_list_ = \ perl_translatable_files_list_ = \
-e 'foreach $$file (@ARGV) {' \ -e 'foreach $$file (@ARGV) {' \
-e ' \# Consider only file extensions with one or two letters' \ -e ' \# Consider only file extensions with one or two letters' \
-e ' $$file =~ /\...?$$/ or next;' \ -e ' $$file =~ /\...?$$/ or next;' \
-e ' \# Ignore mk files' \ -e ' \# Ignore mk files' \
-e ' $$file =~ /\.mk$$/ and next;' \ -e ' $$file =~ /\.mk$$/ and next;' \
-e ' \# Ignore a .c or .h file with a corresponding .l or .y file' \ -e ' \# Ignore a .c or .h file with a corresponding .l or .y file' \
-e ' $$file =~ /(.+)\.[ch]$$/ && (-e "$${1}.l" || -e "$${1}.y")' \ -e ' $$file =~ /(.+)\.[ch]$$/ && (-e "$${1}.l" || -e "$${1}.y")' \
-e ' and next;' \ -e ' and next;' \
-e ' \# Skip unreadable files' \ -e ' \# Skip unreadable files' \
-e ' -r $$file or next;' \ -e ' -r $$file or next;' \
-e ' print "$$file ";' \ -e ' print "$$file ";' \
-e '}' -e '}'
# Verify that all source files using _() (more specifically, files that # Verify that all source files using _() (more specifically, files that
@ -1262,17 +1261,17 @@ _gl_translatable_string_re ?= \b(N?_|gettext *)\([^)"]*("|$$)
# sc_po_check can fail if generated files are not built first # sc_po_check can fail if generated files are not built first
sc_po_check: sc_po_check:
@if test -f $(po_file); then \ @if test -f $(po_file); then \
$(GREP) -E -v '^(#|$$)' $(po_file) | sort > $@-1; \ $(GREP) -E -v '^(#|$$)' $(po_file) | sort > $@-1; \
{ $(VC_LIST_EXCEPT); echo $(generated_files); } \ { $(VC_LIST_EXCEPT); echo $(generated_files); } \
| xargs perl $(perl_translatable_files_list_) \ | xargs perl $(perl_translatable_files_list_) \
| xargs $(GREP) -E -l '$(_gl_translatable_string_re)' \ | xargs $(GREP) -E -l '$(_gl_translatable_string_re)' \
| $(SED) 's|^$(_dot_escaped_builddir)/||' \ | $(SED) 's|^$(_dot_escaped_builddir)/||' \
| $(SED) 's|^$(_dot_escaped_srcdir)/||' \ | $(SED) 's|^$(_dot_escaped_srcdir)/||' \
| sort -u > $@-2; \ | sort -u > $@-2; \
diff -u -L $(po_file) -L $(po_file) $@-1 $@-2 \ diff -u -L $(po_file) -L $(po_file) $@-1 $@-2 \
|| { printf $(fix_po_file_diag) 1>&2; exit 1; }; \ || { printf $(fix_po_file_diag) 1>&2; exit 1; }; \
rm -f $@-1 $@-2; \ rm -f $@-1 $@-2; \
fi fi
linguas_file = $(top_srcdir)/po/LINGUAS linguas_file = $(top_srcdir)/po/LINGUAS
@ -1288,17 +1287,17 @@ sc_linguas_sorting:
# tests many undefined macros, and so we can't enable that option. # tests many undefined macros, and so we can't enable that option.
# So at least preclude common boolean strings as macro values. # So at least preclude common boolean strings as macro values.
sc_Wundef_boolean: sc_Wundef_boolean:
@prohibit='^#define.*(yes|no|true|false)$$' \ @prohibit='^#define.*(yes|no|true|false)$$' \
in_files='$(CONFIG_INCLUDE)' \ in_files='$(CONFIG_INCLUDE)' \
halt='Use 0 or 1 for macro values' \ halt='Use 0 or 1 for macro values' \
$(_sc_search_regexp) $(_sc_search_regexp)
# Even if you use pathmax.h to guarantee that PATH_MAX is defined, it might # Even if you use pathmax.h to guarantee that PATH_MAX is defined, it might
# not be constant, or might overflow a stack. In general, use PATH_MAX as # not be constant, or might overflow a stack. In general, use PATH_MAX as
# a limit, not an array or alloca size. # a limit, not an array or alloca size.
sc_prohibit_path_max_allocation: sc_prohibit_path_max_allocation:
@prohibit='(\balloca *\([^)]*|\[[^]]*)\bPATH_MAX' \ @prohibit='(\balloca *\([^)]*|\[[^]]*)\bPATH_MAX' \
halt='Avoid stack allocations of size PATH_MAX' \ halt='Avoid stack allocations of size PATH_MAX' \
$(_sc_search_regexp) $(_sc_search_regexp)
ifneq ($(_gl-Makefile),) ifneq ($(_gl-Makefile),)
@ -1340,9 +1339,9 @@ sc_group-qemu-caps:
--check --prefix $(top_srcdir)/ --check --prefix $(top_srcdir)/
sc_prohibit_enum_impl_with_vir_prefix_in_virsh: sc_prohibit_enum_impl_with_vir_prefix_in_virsh:
@prohibit='VIR_ENUM_(IMPL|DECL)\(vir[^s]' \ @prohibit='VIR_ENUM_(IMPL|DECL)\(vir[^s]' \
in_vc_files='tools/virsh.*\.[ch]$$' \ in_vc_files='tools/virsh.*\.[ch]$$' \
halt='avoid "vir" prefix for enums in virsh' \ halt='avoid "vir" prefix for enums in virsh' \
$(_sc_search_regexp) $(_sc_search_regexp)
@ -1487,9 +1486,6 @@ exclude_file_name_regexp--sc_prohibit_dirent_d_type = \
exclude_file_name_regexp--sc_prohibit_strcmp = \ exclude_file_name_regexp--sc_prohibit_strcmp = \
^(tools/nss/libvirt_nss.*\.c|tools/virt-login-shell\.c) ^(tools/nss/libvirt_nss.*\.c|tools/virt-login-shell\.c)
exclude_file_name_regexp--sc_prohibit_backslash_alignment = \
^build-aux/syntax-check\.mk$$
exclude_file_name_regexp--sc_prohibit_select = \ exclude_file_name_regexp--sc_prohibit_select = \
^build-aux/syntax-check\.mk|src/util/vireventglibwatch\.c|tests/meson\.build$$ ^build-aux/syntax-check\.mk|src/util/vireventglibwatch\.c|tests/meson\.build$$
@ -1603,67 +1599,67 @@ export ignore_case =
_ignore_case = $$(test -n "$$ignore_case" && printf %s -i || :) _ignore_case = $$(test -n "$$ignore_case" && printf %s -i || :)
define _sc_say_and_exit define _sc_say_and_exit
dummy=; : so we do not need a semicolon before each use; \ dummy=; : so we do not need a semicolon before each use; \
{ printf '%s\n' "$$msg" 1>&2; exit 1; }; { printf '%s\n' "$$msg" 1>&2; exit 1; };
endef endef
define _sc_search_regexp define _sc_search_regexp
dummy=; : so we do not need a semicolon before each use; \ dummy=; : so we do not need a semicolon before each use; \
\ \
: Check arguments; \ : Check arguments; \
test -n "$$prohibit" && test -n "$$require" \ test -n "$$prohibit" && test -n "$$require" \
&& { msg='Cannot specify both prohibit and require' \ && { msg='Cannot specify both prohibit and require' \
$(_sc_say_and_exit) } || :; \ $(_sc_say_and_exit) } || :; \
test -z "$$prohibit" && test -z "$$require" \ test -z "$$prohibit" && test -z "$$require" \
&& { msg='Should specify either prohibit or require' \ && { msg='Should specify either prohibit or require' \
$(_sc_say_and_exit) } || :; \ $(_sc_say_and_exit) } || :; \
test -z "$$prohibit" && test -n "$$exclude" \ test -z "$$prohibit" && test -n "$$exclude" \
&& { msg='Use of exclude requires a prohibit pattern' \ && { msg='Use of exclude requires a prohibit pattern' \
$(_sc_say_and_exit) } || :; \ $(_sc_say_and_exit) } || :; \
test -n "$$in_vc_files" && test -n "$$in_files" \ test -n "$$in_vc_files" && test -n "$$in_files" \
&& { msg='Cannot specify both in_vc_files and in_files' \ && { msg='Cannot specify both in_vc_files and in_files' \
$(_sc_say_and_exit) } || :; \ $(_sc_say_and_exit) } || :; \
test "x$$halt" != x \ test "x$$halt" != x \
|| { msg='halt not defined' $(_sc_say_and_exit) }; \ || { msg='halt not defined' $(_sc_say_and_exit) }; \
\ \
: Filter by file name; \ : Filter by file name; \
if test -n "$$in_files"; then \ if test -n "$$in_files"; then \
files=$$(find $(top_srcdir) | $(GREP) -E "$$in_files" \ files=$$(find $(top_srcdir) | $(GREP) -E "$$in_files" \
| $(GREP) -Ev '$(_sc_excl)'); \ | $(GREP) -Ev '$(_sc_excl)'); \
else \ else \
files=$$($(VC_LIST_EXCEPT)); \ files=$$($(VC_LIST_EXCEPT)); \
if test -n "$$in_vc_files"; then \ if test -n "$$in_vc_files"; then \
files=$$(echo "$$files" | $(GREP) -E "$$in_vc_files"); \ files=$$(echo "$$files" | $(GREP) -E "$$in_vc_files"); \
fi; \ fi; \
fi; \ fi; \
\ \
: Filter by content; \ : Filter by content; \
test -n "$$files" \ test -n "$$files" \
&& test -n "$$containing" \ && test -n "$$containing" \
&& { files=$$(echo "$$files" | xargs $(GREP) -l "$$containing"); } \ && { files=$$(echo "$$files" | xargs $(GREP) -l "$$containing"); } \
|| :; \ || :; \
test -n "$$files" \ test -n "$$files" \
&& test -n "$$non_containing" \ && test -n "$$non_containing" \
&& { files=$$(echo "$$files" | xargs $(GREP) -vl "$$non_containing"); } \ && { files=$$(echo "$$files" | xargs $(GREP) -vl "$$non_containing"); } \
|| :; \ || :; \
\ \
: Check for the construct; \ : Check for the construct; \
if test -n "$$files"; then \ if test -n "$$files"; then \
if test -n "$$prohibit"; then \ if test -n "$$prohibit"; then \
echo "$$files" \ echo "$$files" \
| xargs $(GREP) $$with_grep_options $(_ignore_case) -nE \ | xargs $(GREP) $$with_grep_options $(_ignore_case) -nE \
"$$prohibit" /dev/null \ "$$prohibit" /dev/null \
| $(GREP) -vE "$${exclude:-^$$}" \ | $(GREP) -vE "$${exclude:-^$$}" \
&& { msg="$$halt" $(_sc_say_and_exit) } \ && { msg="$$halt" $(_sc_say_and_exit) } \
|| :; \ || :; \
else \ else \
echo "$$files" \ echo "$$files" \
| xargs \ | xargs \
$(GREP) $$with_grep_options $(_ignore_case) -LE "$$require" \ $(GREP) $$with_grep_options $(_ignore_case) -LE "$$require" \
| $(GREP) . \ | $(GREP) . \
&& { msg="$$halt" $(_sc_say_and_exit) } \ && { msg="$$halt" $(_sc_say_and_exit) } \
|| :; \ || :; \
fi \ fi \
else :; \ else :; \
fi || :; fi || :;
endef endef

View File

@ -140,7 +140,7 @@ endif
CI_GIT_ARGS = \ CI_GIT_ARGS = \
-c advice.detachedHead=false \ -c advice.detachedHead=false \
-q \ -q \
--local \ --local \
$(NULL) $(NULL)
# Args to use when running the container # Args to use when running the container