checkpatch: emit an error when using predefined timestamp macros
authorJoe Perches <joe@perches.com>
Fri, 13 Feb 2015 22:38:18 +0000 (14:38 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sat, 14 Feb 2015 05:21:39 +0000 (21:21 -0800)
Since commit fe7c36c7bde1 ("Makefile: Build with -Werror=date-time if
the compiler supports it"), use of __DATE__, __TIME__, and __TIMESTAMP__
has not been allowed.

As this test is gcc version specific (> 4.9), it hasn't prevented a few
new uses from creeping into the kernel sources.

Make checkpatch complain about them.

Signed-off-by: Joe Perches <joe@perches.com>
Original-patch-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
scripts/checkpatch.pl

index f0bb6d60c07b182686ff203ca3c4fee90e954ab8..501c286369c919015f0a675502b4abdcd3ad24d2 100755 (executable)
@@ -5089,6 +5089,12 @@ sub process {
                        }
                }
 
+# check for uses of __DATE__, __TIME__, __TIMESTAMP__
+               while ($line =~ /\b(__(?:DATE|TIME|TIMESTAMP)__)\b/g) {
+                       ERROR("DATE_TIME",
+                             "Use of the '$1' macro makes the build non-deterministic\n" . $herecurr);
+               }
+
 # check for use of yield()
                if ($line =~ /\byield\s*\(\s*\)/) {
                        WARN("YIELD",