From patchwork Tue Apr 5 14:59:21 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Marek X-Patchwork-Id: 687421 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p35F5poq029094 for ; Tue, 5 Apr 2011 15:07:23 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754485Ab1DEPA6 (ORCPT ); Tue, 5 Apr 2011 11:00:58 -0400 Received: from cantor.suse.de ([195.135.220.2]:44476 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754171Ab1DEO7l (ORCPT ); Tue, 5 Apr 2011 10:59:41 -0400 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.221.2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.suse.de (Postfix) with ESMTP id B9C40950D2; Tue, 5 Apr 2011 16:59:36 +0200 (CEST) Received: by sepie.suse.cz (Postfix, from userid 10020) id 4E442764D7; Tue, 5 Apr 2011 16:59:36 +0200 (CEST) From: Michal Marek To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Andy Whitcroft Subject: [PATCH 34/34] checkpatch: Warn about usage of __DATE__, __TIME__ and __TIMESTAMP__ Date: Tue, 5 Apr 2011 16:59:21 +0200 Message-Id: <1302015561-21047-35-git-send-email-mmarek@suse.cz> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1302015561-21047-1-git-send-email-mmarek@suse.cz> References: <1302015561-21047-1-git-send-email-mmarek@suse.cz> Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Tue, 05 Apr 2011 15:07:48 +0000 (UTC) The __TIME__ and __DATE__ macros are evil. Every C textbook mentions them, but forgets to add the tiny detail that they make sure that your code will never result in the same binary. __TIMESTAMP__ is a bit more sane, but again produces noise as soon as you switch branches back and forth, or apply a patch and revert it. Cc: Andy Whitcroft Signed-off-by: Michal Marek --- scripts/checkpatch.pl | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 4c0383d..dbcdf04 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -2804,6 +2804,11 @@ sub process { WARN("__func__ should be used instead of gcc specific __FUNCTION__\n" . $herecurr); } +# check for pointless usage of __TIME__ and friends + if ($line =~ /\b__(TIME|DATE|TIMESTAMP)__\b/) { + WARN("Usage of __$1__ should be avoided to keep the build deterministic\n" . $herecurr); + } + # check for semaphores initialized locked if ($line =~ /^.\s*sema_init.+,\W?0\W?\)/) { WARN("consider using a completion\n" . $herecurr);