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 DDC20C77B71 for ; Tue, 18 Apr 2023 07:38:03 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id ADBA9859DE; Tue, 18 Apr 2023 09:38:01 +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="ZGLokeEn"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D6D2585A48; Tue, 18 Apr 2023 09:37:59 +0200 (CEST) Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) (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 8E70E85732 for ; Tue, 18 Apr 2023 09:37:56 +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 fllv0035.itg.ti.com ([10.64.41.0]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 33I7bpkB104184; Tue, 18 Apr 2023 02:37:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1681803471; bh=YVtWqr17BXw0iv2zICH6ZP+zVFXtuBIqyP5sckbbk7o=; h=Date:Subject:To:CC:References:From:In-Reply-To; b=ZGLokeEnflmvte7dux3jHcuFcLoLVQyHSqTh5g53ebVhx9f8BpWGIGJAcvKDalHmL vEQpif0ySpBu+NmA5oUdoAqxW/y+9+YoN28Bl4KEPStXdQb0nptLAwur7/0Lga4ErK uH4q6Seajj1NqD/E5QGGQLS9Ph85JkwpkdpxhXQ8= Received: from DFLE113.ent.ti.com (dfle113.ent.ti.com [10.64.6.34]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 33I7bpSu089754 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 18 Apr 2023 02:37:51 -0500 Received: from DFLE108.ent.ti.com (10.64.6.29) by DFLE113.ent.ti.com (10.64.6.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.16; Tue, 18 Apr 2023 02:37:51 -0500 Received: from lelv0326.itg.ti.com (10.180.67.84) by DFLE108.ent.ti.com (10.64.6.29) 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; Tue, 18 Apr 2023 02:37:51 -0500 Received: from [172.24.145.96] (ileaxei01-snat.itg.ti.com [10.180.69.5]) by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id 33I7bm8r031062; Tue, 18 Apr 2023 02:37:49 -0500 Message-ID: <1a6ece09-001a-3449-2b07-4c8b80f810e1@ti.com> Date: Tue, 18 Apr 2023 13:07:48 +0530 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: [PATCH V7 14/14] common: Replace #ifdef and #if with if's To: Devarsh Thakkar , , CC: , , References: <20230410072843.97922-1-n-jain1@ti.com> <20230410072843.97922-15-n-jain1@ti.com> Content-Language: en-US From: Nikhil M Jain In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit 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 Hi Devarsh On 17/04/23 11:09, Devarsh Thakkar wrote: > Hi Nikhil, > > Thanks for the patch. > > On 10/04/23 12:58, Nikhil M Jain wrote: >> Remove #ifdef in header file to avoid multiple definitions while > > multiple definitions doesnt seem to be right phrase as that will give > compilation error anyway. >> compilation. To improve code readability use if() rather than if's and >> '#ifdef's'. > > 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 >> --- >> V7(patch introduced): >> - Replace #ifdef and #if with if's. >> >> common/bmp.c | 12 +++--------- >> common/splash.c | 12 ++++++------ >> include/splash.h | 12 ------------ >> 3 files changed, 9 insertions(+), 27 deletions(-) >> >> diff --git a/common/bmp.c b/common/bmp.c >> index 51766b3c21..62b2d07d23 100644 >> --- a/common/bmp.c >> +++ b/common/bmp.c >> @@ -33,7 +33,7 @@ >> * Returns NULL if decompression failed, or if the decompressed data >> * didn't contain a valid BMP signature. > > or decompression is not enabled in Kconfig. >> */ >> -#if CONFIG_IS_ENABLED(VIDEO_BMP_GZIP) >> + > nitpick, blank line. >> struct bmp_image *gunzip_bmp(unsigned long addr, unsigned long *lenp, >> void **alloc_addr) >> { >> @@ -41,6 +41,8 @@ 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,14 +79,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 > > Don't you want to remove this too and switch to if ? I will remove it. >> void bmp_reloc(void) { >> diff --git a/common/splash.c b/common/splash.c >> index a4e68b7042..4c38a155d0 100644 >> --- a/common/splash.c >> +++ b/common/splash.c >> @@ -79,7 +79,7 @@ static int splash_video_logo_load(void) >> } >> >> memcpy((void *)bmp_load_addr, bmp_logo_bitmap, >> - ARRAY_SIZE(bmp_logo_bitmap)); >> + ARRAY_SIZE(bmp_logo_bitmap)); > > Is this intended? Does checkpatch work fine with that? >> I will do a recheck. >> return 0; >> } >> @@ -96,11 +96,12 @@ __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 (!CONFIG_IS_ENABLED(SPLASH_SCREEN_ALIGN)) >> + return; >> if (!s) >> return; > > You can combine above both in a single statement using || >> I will combine them. >> @@ -117,7 +118,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) >> > > Don't you intend to remove above too and switch to if for all #ifdefs ? >> @@ -159,13 +159,14 @@ 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) && CONFIG_IS_ENABLED(BMP))) >> + return -ENOSYS; > > I think BMP check should come under bmp specific code latter in the function. > Yes, it will be better if we just keep BMP check for bmp_display function. > Regards > Devarsh Thanks, Nikhil >> s = env_get("splashimage"); >> if (!s) >> return -EINVAL; >> @@ -189,4 +190,3 @@ int splash_display(void) >> end: >> return ret; >> } >> -#endif >> diff --git a/include/splash.h b/include/splash.h >> index aa0c14024e..8f15adf9dd 100644 >> --- a/include/splash.h >> +++ b/include/splash.h >> @@ -61,21 +61,9 @@ static inline int splash_source_load(struct splash_location *locations, >> >> 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 >> >> #endif >> \ No newline at end of file