[U-Boot] [PATCH 3/5] cmd_bmp: use bmp_layout API
Nikita Kiryanov
nikita at compulab.co.il
Mon Feb 4 12:39:37 CET 2013
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 <nikita at compulab.co.il>
Signed-off-by: Igor Grinberg <grinberg at compulab.co.il>
Cc: Anatolij Gustschin <agust at denx.de>
Cc: Wolfgang Denk <wd at denx.de>
Cc: Albert ARIBAUD <albert.u.boot at aribaud.net>
Cc: Jeroen Hofstee <jeroen at myspectrum.nl>
---
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) {
--
1.7.10.4
More information about the U-Boot
mailing list