From patchwork Fri Sep 21 22:28:17 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kim Phillips X-Patchwork-Id: 185968 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 038622C008A for ; Sat, 22 Sep 2012 08:46:16 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 356C128089; Sat, 22 Sep 2012 00:46:14 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Da7T9-IFxbLZ; Sat, 22 Sep 2012 00:46:13 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B87122808B; Sat, 22 Sep 2012 00:46:06 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 43CD928089 for ; Sat, 22 Sep 2012 00:45:51 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id cwRBZNN46W2N for ; Sat, 22 Sep 2012 00:45:49 +0200 (CEST) X-Greylist: delayed 908 seconds by postgrey-1.27 at theia; Sat, 22 Sep 2012 00:45:44 CEST X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from tx2outboundpool.messaging.microsoft.com (tx2ehsobe003.messaging.microsoft.com [65.55.88.13]) by theia.denx.de (Postfix) with ESMTPS id 9929528086 for ; Sat, 22 Sep 2012 00:45:44 +0200 (CEST) Received: from mail93-tx2-R.bigfish.com (10.9.14.250) by TX2EHSOBE006.bigfish.com (10.9.40.26) with Microsoft SMTP Server id 14.1.225.23; Fri, 21 Sep 2012 22:30:34 +0000 Received: from mail93-tx2 (localhost [127.0.0.1]) by mail93-tx2-R.bigfish.com (Postfix) with ESMTP id 230894C00F9 for ; Fri, 21 Sep 2012 22:30:34 +0000 (UTC) X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPV:NLI; H:mail.freescale.net; RD:none; EFVD:NLI X-SpamScore: 1 X-BigFish: VS1(zzd6f1izz1202h1d1ah1d2ahzz8275bhz2dh2a8h668h839h944hd24he5bhf0ah107ah1220h1288h12a5h12a9h12bdh137ah1155h) Received: from mail93-tx2 (localhost.localdomain [127.0.0.1]) by mail93-tx2 (MessageSwitch) id 1348266632517124_17537; Fri, 21 Sep 2012 22:30:32 +0000 (UTC) Received: from TX2EHSMHS013.bigfish.com (unknown [10.9.14.254]) by mail93-tx2.bigfish.com (Postfix) with ESMTP id 785C526005A for ; Fri, 21 Sep 2012 22:30:32 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by TX2EHSMHS013.bigfish.com (10.9.99.113) with Microsoft SMTP Server (TLS) id 14.1.225.23; Fri, 21 Sep 2012 22:30:32 +0000 Received: from tx30smr01.am.freescale.net (10.81.153.31) by 039-SN1MMR1-002.039d.mgd.msft.net (10.84.1.15) with Microsoft SMTP Server (TLS) id 14.2.309.3; Fri, 21 Sep 2012 17:30:31 -0500 Received: from x9.am.freescale.net (x9.am.freescale.net [10.82.120.9]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with SMTP id q8LMUTGm009398; Fri, 21 Sep 2012 15:30:31 -0700 Date: Fri, 21 Sep 2012 17:28:17 -0500 From: Kim Phillips To: Message-ID: <20120921172817.ba61bb4052aaad2abdc8e29d@freescale.com> Organization: Freescale Semiconductor, Inc. X-Mailer: Sylpheed 3.2.0beta5 (GTK+ 2.24.10; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-OriginatorOrg: freescale.com Cc: Kumar Gala Subject: [U-Boot] [PATCH] add check infrastructure, default sparse X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Add support for running source code checkers on u-boot source, e.g., using sparse to aid with typechecking. This comes in especially handy as SoC vendors mix and match cores and devices with different endianness, thus here we add CHECK_ENDIAN to the otherwise linux kernel default CHECKFLAGS. Signed-off-by: Kim Phillips --- Makefile | 18 ++++++++++++++++++ config.mk | 9 +++++++++ 2 files changed, 27 insertions(+) diff --git a/Makefile b/Makefile index 058fb53..6969763 100644 --- a/Makefile +++ b/Makefile @@ -92,6 +92,24 @@ BUILD_DIR := $(O) endif endif +# Call a source code checker (by default, "sparse") as part of the +# C compilation. +# +# Use 'make C=1' to enable checking of re-compiled files. +# +# See the linux kernel file "Documentation/sparse.txt" for more details, +# including where to get the "sparse" utility. + +ifdef C +ifeq ("$(origin C)", "command line") +CHECKSRC := $(C) +endif +endif +ifndef CHECKSRC + CHECKSRC = 0 +endif +export CHECKSRC + ifneq ($(BUILD_DIR),) saved-output := $(BUILD_DIR) diff --git a/config.mk b/config.mk index c3822a2..e572902 100644 --- a/config.mk +++ b/config.mk @@ -148,6 +148,7 @@ OBJCOPY = $(CROSS_COMPILE)objcopy OBJDUMP = $(CROSS_COMPILE)objdump RANLIB = $(CROSS_COMPILE)RANLIB DTC = dtc +CHECK = sparse ######################################################################### @@ -274,6 +275,10 @@ ifneq ($(CONFIG_SPL_TEXT_BASE),) LDFLAGS_u-boot-spl += -Ttext $(CONFIG_SPL_TEXT_BASE) endif +# Linus' kernel sanity checking tool +CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \ + -Wbitwise -Wno-return-void -D__CHECK_ENDIAN__ $(CF) + # Location of a usable BFD library, where we define "usable" as # "built for ${HOST}, supports ${TARGET}". Sensible values are # - When cross-compiling: the root of the cross-environment @@ -321,6 +326,9 @@ $(obj)%.s: %.S $(obj)%.o: %.S $(CC) $(ALL_AFLAGS) -o $@ $< -c $(obj)%.o: %.c +ifneq ($(CHECKSRC),0) + $(CHECK) $(CHECKFLAGS) $(ALL_CFLAGS) $< +endif $(CC) $(ALL_CFLAGS) -o $@ $< -c $(obj)%.i: %.c $(CPP) $(ALL_CFLAGS) -o $@ $< -c