util/lint/kconfig_lint: Fix operator precedence issue

Perl 5.42.0 added a new warning for possible precedence problems between
the `!` logical negation operator and various other operators [1]. In
particular, the kconfig_lint script uses `!` and `=~` (binding operator)
to check that a filename does not match a regex, but was written in a
way that would be parsed as negating the filename and then comparing it
to the regex. The resulting warning from the newer version of Perl
caused lint-stable to fail on the lint-stable-008-kconfig test due to
the non empty output, causing the pre-commit hook to fail.

Fix this by using the negated binding operator `!~` instead as
recommended by the Perl documentation [2].

[1] https://perldoc.perl.org/perl5420delta#New-Warnings
[2] https://perldoc.perl.org/perldiag#Possible-precedence-problem-between-!-and-%25s

Change-Id: I3631b8b0be92bf85a1510be1f1d4221a010be1ba
Signed-off-by: Nicholas Chin <nic.c3.14@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/88619
Reviewed-by: Nicholas Sudsgaard <devel+coreboot@nsudsgaard.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Nicholas Chin 2025-07-30 21:13:16 -06:00 committed by Matt DeVillier
commit 280d3a25e8

View file

@ -1347,8 +1347,8 @@ sub print_wholeconfig {
sub check_if_file_referenced {
my $filename = $File::Find::name;
if ( ( $filename =~ /Kconfig/ )
&& ( !$filename =~ /\.orig$/ )
&& ( !$filename =~ /~$/ )
&& ( $filename !~ /\.orig$/ )
&& ( $filename !~ /~$/ )
&& ( !exists $loaded_files{$filename} ) )
{
show_warning("'$filename' is never referenced");