Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 79EA5C77B72 for ; Thu, 20 Apr 2023 12:14:55 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 40E2186362; Thu, 20 Apr 2023 14:12:16 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=ti.com header.i=@ti.com header.b="lqEIzpSw"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 348CA8634D; Thu, 20 Apr 2023 14:11:45 +0200 (CEST) Received: from lelv0142.ext.ti.com (lelv0142.ext.ti.com [198.47.23.249]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 7F23E8634E for ; Thu, 20 Apr 2023 14:11:37 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=n-jain1@ti.com Received: from lelv0265.itg.ti.com ([10.180.67.224]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 33KCBZHu022164; Thu, 20 Apr 2023 07:11:35 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1681992695; bh=lc9uNY6itznW95SwPx17mRRUVDAY5bY5I/7u5JrZ61M=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=lqEIzpSwG+u+waZzQJsJBpOx01kflxNG65fV6BoE0mxUv00qwRP/i4AbIRONMsNnX oPd2ldDXwYw7SHJTIwZzxO15817pm/JKfCuX+2f2rjQnSWw1+TMDzuXv7h+GVOkMa+ fPXXpVPSLpPgl+4xoAr2fNWq0xVKJl36d9i6aTJo= Received: from DLEE113.ent.ti.com (dlee113.ent.ti.com [157.170.170.24]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 33KCBZSB004452 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 20 Apr 2023 07:11:35 -0500 Received: from DLEE115.ent.ti.com (157.170.170.26) by DLEE113.ent.ti.com (157.170.170.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.16; Thu, 20 Apr 2023 07:11:34 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) by DLEE115.ent.ti.com (157.170.170.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.16 via Frontend Transport; Thu, 20 Apr 2023 07:11:35 -0500 Received: from localhost (ileaxei01-snat2.itg.ti.com [10.180.69.6]) by lelv0327.itg.ti.com (8.15.2/8.15.2) with ESMTP id 33KCBYnI075326; Thu, 20 Apr 2023 07:11:34 -0500 From: Nikhil M Jain To: , , CC: , , , Subject: [PATCH V9 14/14] common: Replace #ifdef and #if with if's Date: Thu, 20 Apr 2023 17:41:12 +0530 Message-ID: <20230420121112.311922-15-n-jain1@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230420121112.311922-1-n-jain1@ti.com> References: <20230420121112.311922-1-n-jain1@ti.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Avoid using preprocessor compilation directives and instead use simple logical expressions for better readability since compiler will anyway optimize out the respective code block if condition is not satisfied. Signed-off-by: Nikhil M Jain Reviewed-by: Simon Glass Reviewed-by: Devarsh Thakkar --- V9: - Add Reviewed-By tag. V8: - Update as per review comments. - Call bmp_display only when CONFIG_BMP is defined. V7(patch introduced): - Replace #ifdef and #if with if's. common/bmp.c | 14 +++++--------- common/splash.c | 14 +++++++------- include/splash.h | 13 ------------- 3 files changed, 12 insertions(+), 29 deletions(-) diff --git a/common/bmp.c b/common/bmp.c index ad91351f19..57764f3653 100644 --- a/common/bmp.c +++ b/common/bmp.c @@ -31,9 +31,9 @@ * by the caller after use. * * Returns NULL if decompression failed, or if the decompressed data - * didn't contain a valid BMP signature. + * didn't contain a valid BMP signature or decompression is not enabled in + * Kconfig. */ -#if CONFIG_IS_ENABLED(VIDEO_BMP_GZIP) struct bmp_image *gunzip_bmp(unsigned long addr, unsigned long *lenp, void **alloc_addr) { @@ -41,6 +41,9 @@ struct bmp_image *gunzip_bmp(unsigned long addr, unsigned long *lenp, unsigned long len; struct bmp_image *bmp; + if (!CONFIG_IS_ENABLED(VIDEO_BMP_GZIP)) + return NULL; + /* * Decompress bmp image */ @@ -77,13 +80,6 @@ struct bmp_image *gunzip_bmp(unsigned long addr, unsigned long *lenp, *alloc_addr = dst; return bmp; } -#else -struct bmp_image *gunzip_bmp(unsigned long addr, unsigned long *lenp, - void **alloc_addr) -{ - return NULL; -} -#endif #ifdef CONFIG_NEEDS_MANUAL_RELOC void bmp_reloc(void) diff --git a/common/splash.c b/common/splash.c index a4e68b7042..6820db683b 100644 --- a/common/splash.c +++ b/common/splash.c @@ -96,12 +96,11 @@ __weak int splash_screen_prepare(void) return splash_video_logo_load(); } -#if CONFIG_IS_ENABLED(SPLASH_SCREEN_ALIGN) void splash_get_pos(int *x, int *y) { char *s = env_get("splashpos"); - if (!s) + if (!CONFIG_IS_ENABLED(SPLASH_SCREEN_ALIGN) || !s) return; if (s[0] == 'm') @@ -117,7 +116,6 @@ void splash_get_pos(int *x, int *y) *y = simple_strtol(s + 1, NULL, 0); } } -#endif /* CONFIG_SPLASH_SCREEN_ALIGN */ #if CONFIG_IS_ENABLED(VIDEO) && !CONFIG_IS_ENABLED(HIDE_LOGO_VERSION) @@ -159,13 +157,13 @@ void splash_display_banner(void) * Common function to show a splash image if env("splashimage") is set. * For additional details please refer to doc/README.splashprepare. */ -#if CONFIG_IS_ENABLED(SPLASH_SCREEN) && CONFIG_IS_ENABLED(BMP) int splash_display(void) { ulong addr; char *s; int x = 0, y = 0, ret; - + if (!CONFIG_IS_ENABLED(SPLASH_SCREEN)) + return -ENOSYS; s = env_get("splashimage"); if (!s) return -EINVAL; @@ -177,7 +175,10 @@ int splash_display(void) splash_get_pos(&x, &y); - ret = bmp_display(addr, x, y); + if (CONFIG_IS_ENABLED(BMP)) + ret = bmp_display(addr, x, y); + else + return -ENOSYS; /* Skip banner output on video console if the logo is not at 0,0 */ if (x || y) @@ -189,4 +190,3 @@ int splash_display(void) end: return ret; } -#endif diff --git a/include/splash.h b/include/splash.h index b6a100ffc3..c392237598 100644 --- a/include/splash.h +++ b/include/splash.h @@ -60,21 +60,8 @@ static inline int splash_source_load(struct splash_location *locations, #endif int splash_screen_prepare(void); - -#if CONFIG_IS_ENABLED(SPLASH_SCREEN_ALIGN) void splash_get_pos(int *x, int *y); -#else -static inline void splash_get_pos(int *x, int *y) { } -#endif - -#if CONFIG_IS_ENABLED(SPLASH_SCREEN) && CONFIG_IS_ENABLED(BMP) int splash_display(void); -#else -static inline int splash_display(void) -{ - return -ENOSYS; -} -#endif #define BMP_ALIGN_CENTER 0x7FFF -- 2.34.1