git: 4748db6ffd42 - main - checkstyle9.pl: Don't use $root if not defined

From: Warner Losh <imp_at_FreeBSD.org>
Date: Sun, 07 Jan 2024 16:51:55 UTC
The branch main has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=4748db6ffd422f8b52d49f5e2982628ac52afb8c

commit 4748db6ffd422f8b52d49f5e2982628ac52afb8c
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2024-01-07 16:50:51 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2024-01-07 16:51:49 +0000

    checkstyle9.pl: Don't use $root if not defined
    
    $root is only defined when given on the command line. Don't try to use
    its value when it's not defined.
    
    Sponsored by:           Netflix
---
 tools/build/checkstyle9.pl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/build/checkstyle9.pl b/tools/build/checkstyle9.pl
index d2c6ea77868d..3b28fef93669 100755
--- a/tools/build/checkstyle9.pl
+++ b/tools/build/checkstyle9.pl
@@ -1410,7 +1410,7 @@ sub process {
 	                checkfilename($realfile, \$acpi_testexpected, \$acpi_nontestexpected);
 
 			$p1_prefix = $1;
-			if (!$file && $tree && $p1_prefix ne '' &&
+			if (!$file && $tree && $p1_prefix ne '' && defined $root &&
 			    -e "$root/$p1_prefix") {
 				WARN("patch prefix '$p1_prefix' exists, appears to be a -p0 patch\n");
 			}