From patchwork Mon Apr 22 12:51:35 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 238528 X-Patchwork-Delegate: sjg@chromium.org 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 18F442C012B for ; Mon, 22 Apr 2013 22:55:34 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 11BB64A54B; Mon, 22 Apr 2013 14:54:43 +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 deblh99PBTQL; Mon, 22 Apr 2013 14:54:42 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id ADF5D4A27F; Mon, 22 Apr 2013 14:53:26 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 8C01F4A1B2 for ; Mon, 22 Apr 2013 14:52:53 +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 2pF2zK9nJthj for ; Mon, 22 Apr 2013 14:52:52 +0200 (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 mail-yh0-f73.google.com (mail-yh0-f73.google.com [209.85.213.73]) by theia.denx.de (Postfix) with ESMTPS id C83E54A20D for ; Mon, 22 Apr 2013 14:52:32 +0200 (CEST) Received: by mail-yh0-f73.google.com with SMTP id i21so674374yha.4 for ; Mon, 22 Apr 2013 05:52:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:x-gm-message-state; bh=ECrfJwQyd+7B8SdZC2UudVt0J+MoSXbJ7hsvWOuZBx4=; b=Bb2ms2SJ5apSN7wfNPMrj4l3nSw4N8jVEIu/4ULuHNkf842ObnQtXMQmlWCwjQ80qH u830xd2uG+R1n5jRplVHy1yI98b1/qxLHnFakfAw9xOIdRWGlSuVHrtOTmkByyBBYTPQ UeSCKmf9qED+cb/gcfJzM/qVPEZtLzlT27zgCL++mAwHJSGtcys6X3p4QF94TpRM4zj4 SrwyD6Dq/xWmrQIE4Y8nViWLI4HLXCwwIGfjlfpunkFF+oVITr+UjXE+aHUwf1ek3p8p x38637ozh4ZFisuJUlBucdhUAzSdsewiliqmhYLfY0B3DZgJzPVHdUEOUZCmy8wdqAPu vtLA== X-Received: by 10.236.135.65 with SMTP id t41mr13136416yhi.42.1366635150836; Mon, 22 Apr 2013 05:52:30 -0700 (PDT) Received: from corp2gmr1-1.hot.corp.google.com (corp2gmr1-1.hot.corp.google.com [172.24.189.92]) by gmr-mx.google.com with ESMTPS id p70si4783860yhd.5.2013.04.22.05.52.30 (version=TLSv1.1 cipher=AES128-SHA bits=128/128); Mon, 22 Apr 2013 05:52:30 -0700 (PDT) Received: from kaka.mtv.corp.google.com (kaka.mtv.corp.google.com [172.22.83.1]) by corp2gmr1-1.hot.corp.google.com (Postfix) with ESMTP id 94B5631C2BA; Mon, 22 Apr 2013 05:52:30 -0700 (PDT) Received: by kaka.mtv.corp.google.com (Postfix, from userid 121222) id 4CC8A1609CA; Mon, 22 Apr 2013 05:52:30 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Date: Mon, 22 Apr 2013 05:51:35 -0700 Message-Id: <1366635107-21588-8-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 1.8.2.1 In-Reply-To: <1366635107-21588-1-git-send-email-sjg@chromium.org> References: <1366635107-21588-1-git-send-email-sjg@chromium.org> X-Gm-Message-State: ALoCoQnR5y2WPruINskNEh3GrlUHlS4tGdITHOpO/Yt5CQ0D6V+dWWQvVIwMOdOmH0tX3Fe+E0f2XMJi+pqobn9udDzOFe6V0B/0J93Yt/fLvKbj2VGHjFXBRUvizIVLwevnCxJz6QQ6/cNeYxvnwf5PJZ1cbs0u603kCj/vZsxy3KOfXjlUHdVK5M9qHvepJuMmoru1wtdR Cc: Tom Rini , Joe Hershberger , u-boot-review@google.com Subject: [U-Boot] [PATCH v3 07/19] image: Move timestamp #ifdefs to header file 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: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Rather than repeat the line #if defined(CONFIG_TIMESTAMP) || defined(CONFIG_CMD_DATE) || \ defined(USE_HOSTCC) everywhere, put this in a header file and #define IMAGE_ENABLE_TIMESTAMP to either 1 or 0. Then we can use a plain if() in most code and avoid the #ifdefs. The compiler's dead code elimination ensures that the result is the same. Signed-off-by: Simon Glass Acked-by: Marek Vasut --- Changes in v3: None Changes in v2: None common/image.c | 50 +++++++++++++++++++++----------------------------- include/image.h | 8 ++++++++ 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/common/image.c b/common/image.c index 60c2127..b415c4e 100644 --- a/common/image.c +++ b/common/image.c @@ -39,9 +39,7 @@ #include #endif -#if defined(CONFIG_TIMESTAMP) || defined(CONFIG_CMD_DATE) #include -#endif #include #include @@ -163,10 +161,6 @@ static const table_entry_t uimage_comp[] = { { -1, "", "", }, }; -#if defined(CONFIG_TIMESTAMP) || defined(CONFIG_CMD_DATE) || defined(USE_HOSTCC) -static void genimg_print_time(time_t timestamp); -#endif - /*****************************************************************************/ /* Legacy format routines */ /*****************************************************************************/ @@ -312,10 +306,10 @@ void image_print_contents(const void *ptr) #endif printf("%sImage Name: %.*s\n", p, IH_NMLEN, image_get_name(hdr)); -#if defined(CONFIG_TIMESTAMP) || defined(CONFIG_CMD_DATE) || defined(USE_HOSTCC) - printf("%sCreated: ", p); - genimg_print_time((time_t)image_get_time(hdr)); -#endif + if (IMAGE_ENABLE_TIMESTAMP) { + printf("%sCreated: ", p); + genimg_print_time((time_t)image_get_time(hdr)); + } printf("%sImage Type: ", p); image_print_type(hdr); printf("%sData Size: ", p); @@ -524,8 +518,8 @@ void genimg_print_size(uint32_t size) #endif } -#if defined(CONFIG_TIMESTAMP) || defined(CONFIG_CMD_DATE) || defined(USE_HOSTCC) -static void genimg_print_time(time_t timestamp) +#if IMAGE_ENABLE_TIMESTAMP +void genimg_print_time(time_t timestamp) { #ifndef USE_HOSTCC struct rtc_time tm; @@ -538,7 +532,7 @@ static void genimg_print_time(time_t timestamp) printf("%s", ctime(×tamp)); #endif } -#endif /* CONFIG_TIMESTAMP || CONFIG_CMD_DATE || USE_HOSTCC */ +#endif /** * get_table_entry_name - translate entry id to long name @@ -1911,9 +1905,7 @@ void fit_print_contents(const void *fit) int count = 0; int ret; const char *p; -#if defined(CONFIG_TIMESTAMP) || defined(CONFIG_CMD_DATE) || defined(USE_HOSTCC) time_t timestamp; -#endif #ifdef USE_HOSTCC p = ""; @@ -1929,14 +1921,14 @@ void fit_print_contents(const void *fit) else printf("%s\n", desc); -#if defined(CONFIG_TIMESTAMP) || defined(CONFIG_CMD_DATE) || defined(USE_HOSTCC) - ret = fit_get_timestamp(fit, 0, ×tamp); - printf("%sCreated: ", p); - if (ret) - printf("unavailable\n"); - else - genimg_print_time(timestamp); -#endif + if (IMAGE_ENABLE_TIMESTAMP) { + ret = fit_get_timestamp(fit, 0, ×tamp); + printf("%sCreated: ", p); + if (ret) + printf("unavailable\n"); + else + genimg_print_time(timestamp); + } /* Find images parent node offset */ images_noffset = fdt_path_offset(fit, FIT_IMAGES_PATH); @@ -3047,13 +3039,13 @@ int fit_check_format(const void *fit) return 0; } -#if defined(CONFIG_TIMESTAMP) || defined(CONFIG_CMD_DATE) || defined(USE_HOSTCC) - /* mandatory / node 'timestamp' property */ - if (fdt_getprop(fit, 0, FIT_TIMESTAMP_PROP, NULL) == NULL) { - debug("Wrong FIT format: no timestamp\n"); - return 0; + if (IMAGE_ENABLE_TIMESTAMP) { + /* mandatory / node 'timestamp' property */ + if (fdt_getprop(fit, 0, FIT_TIMESTAMP_PROP, NULL) == NULL) { + debug("Wrong FIT format: no timestamp\n"); + return 0; + } } -#endif /* mandatory subimages parent '/images' node */ if (fdt_path_offset(fit, FIT_IMAGES_PATH) < 0) { diff --git a/include/image.h b/include/image.h index 4ad0e6b..d2325dd 100644 --- a/include/image.h +++ b/include/image.h @@ -333,6 +333,14 @@ int genimg_get_type_id(const char *name); int genimg_get_comp_id(const char *name); void genimg_print_size(uint32_t size); +#if defined(CONFIG_TIMESTAMP) || defined(CONFIG_CMD_DATE) || \ + defined(USE_HOSTCC) +#define IMAGE_ENABLE_TIMESTAMP 1 +#else +#define IMAGE_ENABLE_TIMESTAMP 0 +#endif +void genimg_print_time(time_t timestamp); + #ifndef USE_HOSTCC /* Image format types, returned by _get_format() routine */ #define IMAGE_FORMAT_INVALID 0x00