diff options
author | Daniel P. Berrangé <berrange@redhat.com> | 2025-05-12 17:11:55 +0100 |
---|---|---|
committer | Daniel P. Berrangé <berrange@redhat.com> | 2025-05-22 11:24:41 +0100 |
commit | f48f16ec3d8cee0a3d843915451c5649fe3a8aaf (patch) | |
tree | d790a6390dadc713ab6ba5fe19056a1ab3966a90 | |
parent | 9bec5f93e794271b2dc643cdc1c43082af958fac (diff) | |
download | qemu-f48f16ec3d8cee0a3d843915451c5649fe3a8aaf.zip qemu-f48f16ec3d8cee0a3d843915451c5649fe3a8aaf.tar.gz qemu-f48f16ec3d8cee0a3d843915451c5649fe3a8aaf.tar.bz2 |
scripts/checkpatch: use new hook for file permissions check
The file permissions check is the kind of check intended to be performed
in the new start of file hook.
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
-rwxr-xr-x | scripts/checkpatch.pl | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 817df98..881dcac 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -1448,6 +1448,17 @@ sub process_file_list { # Called at the start of processing a diff hunk for a file sub process_start_of_file { my $fileinfo = shift; + + # Check for incorrect file permissions + if ($fileinfo->{action} eq "new" && ($fileinfo->{mode} & 0111)) { + my $permhere = $fileinfo->{linestart} . "FILE: " . + $fileinfo->{filenew} . "\n"; + if ($fileinfo->{filenew} =~ + /(\bMakefile(?:\.objs)?|\.(c|cc|cpp|h|mak|s|S))$/) { + ERROR("do not set execute permissions for source " . + "files\n" . $permhere); + } + } } # Called at the end of processing a diff hunk for a file @@ -1719,14 +1730,6 @@ sub process { $cnt_lines++ if ($realcnt != 0); -# Check for incorrect file permissions - if ($line =~ /^new (file )?mode.*[7531]\d{0,2}$/) { - my $permhere = $here . "FILE: $realfile\n"; - if ($realfile =~ /(\bMakefile(?:\.objs)?|\.c|\.cc|\.cpp|\.h|\.mak|\.[sS])$/) { - ERROR("do not set execute permissions for source files\n" . $permhere); - } - } - # Only allow Python 3 interpreter if ($realline == 1 && $line =~ /^\+#!\ *\/usr\/bin\/(?:env )?python$/) { |