From patchwork Mon Feb 4 11:39:37 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikita Kiryanov X-Patchwork-Id: 217876 X-Patchwork-Delegate: wd@denx.de 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 387642C0294 for ; Mon, 4 Feb 2013 22:40:20 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 0FC8C4A08D; Mon, 4 Feb 2013 12:40:14 +0100 (CET) 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 JPQokH58rhDJ; Mon, 4 Feb 2013 12:40:13 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 850514A08E; Mon, 4 Feb 2013 12:39:58 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 6301D4A051 for ; Mon, 4 Feb 2013 12:39:54 +0100 (CET) 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 GyfTSaqiR4Qb for ; Mon, 4 Feb 2013 12:39:52 +0100 (CET) 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 compulab.co.il (softlayer.compulab.co.il [50.23.254.55]) by theia.denx.de (Postfix) with ESMTPS id 3BAB64A02F for ; Mon, 4 Feb 2013 12:39:51 +0100 (CET) Received: from [82.166.188.245] (port=42413 helo=zimbra-mta.compulab.co.il) by softlayer.compulab.co.il with esmtp (Exim 4.80) (envelope-from ) id 1U2KOq-0006gU-Pj; Mon, 04 Feb 2013 13:39:49 +0200 Received: from localhost (localhost.localdomain [127.0.0.1]) by zimbra-mta.compulab.co.il (Postfix) with ESMTP id CB341644194; Mon, 4 Feb 2013 13:39:47 +0200 (IST) X-Virus-Scanned: amavisd-new at compulab.co.il Received: from zimbra-mta.compulab.co.il ([127.0.0.1]) by localhost (zimbra-mta.compulab.co.il [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id vg6jLrTIMDuS; Mon, 4 Feb 2013 13:39:46 +0200 (IST) Received: from compulab.co.il (nikita-pc.compulab.local [192.168.11.211]) by zimbra-mta.compulab.co.il (Postfix) with ESMTP id CECED644195; Mon, 4 Feb 2013 13:39:46 +0200 (IST) Received: by compulab.co.il (Postfix, from userid 1000) id 06B35FC012C; Mon, 4 Feb 2013 13:39:47 +0200 (IST) From: Nikita Kiryanov To: u-boot@lists.denx.de Date: Mon, 4 Feb 2013 13:39:37 +0200 Message-Id: <1359977979-28585-4-git-send-email-nikita@compulab.co.il> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1359977979-28585-1-git-send-email-nikita@compulab.co.il> References: <1359977979-28585-1-git-send-email-nikita@compulab.co.il> X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - softlayer.compulab.co.il X-AntiAbuse: Original Domain - lists.denx.de X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - compulab.co.il X-Get-Message-Sender-Via: softlayer.compulab.co.il: acl_c_relayhosts_text_entry: nikita@compulab.co.il|compulab.co.il Cc: Jeroen Hofstee Subject: [U-Boot] [PATCH 3/5] cmd_bmp: use bmp_layout API 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 If the BMP headers are located in unaligned addresses, accessing them directly may lead to a data abort on some architectures. Use the safer bmp_layout API instead. Signed-off-by: Nikita Kiryanov Signed-off-by: Igor Grinberg Cc: Anatolij Gustschin Cc: Wolfgang Denk Cc: Albert ARIBAUD Cc: Jeroen Hofstee --- common/cmd_bmp.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/common/cmd_bmp.c b/common/cmd_bmp.c index 5a52edd..0713ba8 100644 --- a/common/cmd_bmp.c +++ b/common/cmd_bmp.c @@ -73,8 +73,7 @@ bmp_image_t *gunzip_bmp(unsigned long addr, unsigned long *lenp) /* * Check for bmp mark 'BM' */ - if (!((bmp->header.signature[0] == 'B') && - (bmp->header.signature[1] == 'M'))) { + if (!bmp_signature_valid(bmp)) { free(dst); return NULL; } @@ -191,8 +190,7 @@ static int bmp_info(ulong addr) bmp_image_t *bmp=(bmp_image_t *)addr; unsigned long len; - if (!((bmp->header.signature[0]=='B') && - (bmp->header.signature[1]=='M'))) + if (!bmp_signature_valid(bmp)) bmp = gunzip_bmp(addr, &len); if (bmp == NULL) { @@ -200,10 +198,10 @@ static int bmp_info(ulong addr) return 1; } - printf("Image size : %d x %d\n", le32_to_cpu(bmp->header.width), - le32_to_cpu(bmp->header.height)); - printf("Bits per pixel: %d\n", le16_to_cpu(bmp->header.bit_count)); - printf("Compression : %d\n", le32_to_cpu(bmp->header.compression)); + printf("Image size : %d x %d\n", bmp_get_width(bmp), + bmp_get_height(bmp)); + printf("Bits per pixel: %d\n", bmp_get_bit_count(bmp)); + printf("Compression : %d\n", bmp_get_compression(bmp)); if ((unsigned long)bmp != addr) free(bmp); @@ -227,8 +225,7 @@ int bmp_display(ulong addr, int x, int y) bmp_image_t *bmp = (bmp_image_t *)addr; unsigned long len; - if (!((bmp->header.signature[0]=='B') && - (bmp->header.signature[1]=='M'))) + if (!bmp_signature_valid(bmp)) bmp = gunzip_bmp(addr, &len); if (!bmp) {