lkml.org 
[lkml]   [2014]   [Dec]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 1/3] checkpatch: Check for use of disallowed macros
From
Date
On Fri, 2014-12-12 at 11:51 +0100, Rasmus Villemoes wrote:
> Since fe7c36c7 ("Makefile: Build with -Werror=date-time if the
> compiler supports it"), use of __DATE__, __TIME__, __TIMESTAMP__ has
> been disallowed. This hasn't prevented a few new users from creeping
> in. Make checkpatch complain.
[]
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
[]
> @@ -3008,6 +3008,12 @@ sub process {
> $line =~ s@//.*@@;
> $opline =~ s@//.*@@;
>
> +
> +# Use of __DATE__, __TIME__, __TIMESTAMP__ is not allowed
> + if ($line =~ m/\b__(?:DATE|TIME|TIMESTAMP)__\b/) {
> + ERROR("DATETIME", "Do not use the macros __DATE__, __TIME__ and __TIMESTAMP__\n" . $herecurr)

I'd probably add that adjacent to the existing __FUNCTION__
test near line 5000 and make the test show the specific macro
used.

Maybe add __LINE__ and __FILE__ as a separate --strict test too.

Also the error message should should show the specific macro and
if __DATE__ and __TIME__ are on the same line, the error should
be emitted twice.

Maybe:
while ($line =~ /\b(__(?:DATE|TIME|TIMESTAMP)__)\b/g) {
ERROR("DATETIME",
"Do not use the $1 macro\n" . $herecurr);
}




\
 
 \ /
  Last update: 2014-12-12 13:01    [W:0.086 / U:0.364 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site