From mboxrd@z Thu Jan 1 00:00:00 1970 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 8DB91C7618D for ; Thu, 6 Apr 2023 07:41:37 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CF36385FBC; Thu, 6 Apr 2023 09:41:33 +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="E/KHtIm3"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 391DE85FC6; Thu, 6 Apr 2023 09:41:32 +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 5028685FAD for ; Thu, 6 Apr 2023 09:41:28 +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=vigneshr@ti.com Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 3367fNOL052091; Thu, 6 Apr 2023 02:41:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1680766883; bh=KOs4WTUFZ3yNnC+1u8rPtTleD8/efyyUx+zURos1y4k=; h=Date:Subject:To:CC:References:From:In-Reply-To; b=E/KHtIm3GIX6PHHvvwEKqjAX6mY2JK5w35EtkQihECLKVBXbqnnN8M25lAP2RxHeF MGo9OHN6GGGpK/lqqH4dpfe1xJGNM3l7k5nwS6blfit2V314W+ltW0/utZJGQgJsZ+ QWZ2elVnV/snjZ4X9ssrC5zeOPig0B1dNOg0xWsc= Received: from DFLE112.ent.ti.com (dfle112.ent.ti.com [10.64.6.33]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 3367fNES013544 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 6 Apr 2023 02:41:23 -0500 Received: from DFLE115.ent.ti.com (10.64.6.36) by DFLE112.ent.ti.com (10.64.6.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.16; Thu, 6 Apr 2023 02:41:22 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DFLE115.ent.ti.com (10.64.6.36) 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, 6 Apr 2023 02:41:22 -0500 Received: from [172.24.145.182] (ileaxei01-snat.itg.ti.com [10.180.69.5]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 3367fKDV042661; Thu, 6 Apr 2023 02:41:21 -0500 Message-ID: Date: Thu, 6 Apr 2023 13:11:20 +0530 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.1 Subject: Re: [PATCH V6 08/13] cmd: bmp: Split bmp commands and functions Content-Language: en-US To: Nikhil M Jain , Simon Glass CC: , , , References: <20230404130610.65022-1-n-jain1@ti.com> <20230404130610.65022-9-n-jain1@ti.com> From: Vignesh Raghavendra In-Reply-To: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit 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 Nikhil, On 06/04/23 11:57, Nikhil M Jain wrote: >>> +struct bmp_image *gunzip_bmp(unsigned long addr, unsigned long *lenp, >>> +                            void **alloc_addr) >>> +{ >>> +       void *dst; >>> +       unsigned long len; >>> +       struct bmp_image *bmp; >>> + >> >> if (!IS_ENABLED(CONFIG_VIDEO_BMP_GZIP)) >>     return NULL; >> > > I preferred to use #if to avoid compilation of code when not required. > > For example,  if someone doesn't want to display a gzip bmp image they > wouldn't want the code to be compiled, so that binary size doesn't > increase. Both are equivalent. Compiler will optimize out the function if CONFIG_VIDEO_BMP_GZIP is not defined. #ifdefs are complicated to read compared to inline if()s (at least for me). > >>> +       /* >>> +        * Decompress bmp image >>> +        */ >>> +       len = CONFIG_VIDEO_LOGO_MAX_SIZE; >>> +       /* allocate extra 3 bytes for 32-bit-aligned-address + 2 >>> alignment */ >>> +       dst = malloc(CONFIG_VIDEO_LOGO_MAX_SIZE + 3); >>> +       if (!dst) { >>> +               puts("Error: malloc in gunzip failed!\n"); >>> +               return NULL; >>> +       } >>> + >>> +       /* align to 32-bit-aligned-address + 2 */ >>> +       bmp = dst + 2; >>> + >>> +       if (gunzip(bmp, CONFIG_VIDEO_LOGO_MAX_SIZE, map_sysmem(addr, 0), >>> +                  &len)) { >>> +               free(dst); >>> +               return NULL; >>> +       } >>> +       if (len == CONFIG_VIDEO_LOGO_MAX_SIZE) >>> +               puts("Image could be truncated (increase >>> CONFIG_VIDEO_LOGO_MAX_SIZE)!\n"); >>> + >>> +       /* >>> +        * Check for bmp mark 'BM' >>> +        */ >>> +       if (!((bmp->header.signature[0] == 'B') && >>> +             (bmp->header.signature[1] == 'M'))) { >>> +               free(dst); >>> +               return NULL; >>> +       } >>> + >>> +       debug("Gzipped BMP image detected!\n"); >>> + >>> +       *alloc_addr = dst; >>> +       return bmp; >>> +} >>> +#else >>> +struct bmp_image *gunzip_bmp(unsigned long addr, unsigned long *lenp, >>> +                            void **alloc_addr) >>> +{ >>> +       return NULL; >>> +} >>> +#endif >>> + [...] -- Regards Vignesh