[Linux-kernel-mentees] [PATCH] checkpatch: add fix for DEPRECATED_VARIABLE

Aditya Srivastava yashsri421 at gmail.com
Sun Nov 1 18:21:06 UTC 2020


The coding style of Makefile has been improved to use certain different
variable names as compared to earlier.

E.g., variable name asflags-y should be used instead of EXTRA_AFLAGS, etc

Currently checkpatch.pl warns the user to change variable name with
its corresponding upgrade, but does not have a fix option

Provide simple fix by substituting the variable name with its
corresponding upgrade.

Signed-off-by: Aditya Srivastava <yashsri421 at gmail.com>
---
 scripts/checkpatch.pl | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index a0107ed257d1..5fd34a862522 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3266,8 +3266,13 @@ sub process {
 				'EXTRA_LDFLAGS' =>  'ldflags-y',
 			};
 
-			WARN("DEPRECATED_VARIABLE",
-			     "Use of $flag is deprecated, please use \`$replacement->{$flag} instead.\n" . $herecurr) if ($replacement->{$flag});
+			if($replacement->{$flag}) {
+				if (WARN("DEPRECATED_VARIABLE",
+					 "Use of $flag is deprecated, please use \`$replacement->{$flag} instead.\n" . $herecurr) &&
+				    $fix) {
+					$fixed[$fixlinenr] =~ s/$flag/$replacement->{$flag}/;
+				}
+			}
 		}
 
 # check for DT compatible documentation
-- 
2.17.1



More information about the Linux-kernel-mentees mailing list