Hello Nikita,

> -----Original Message-----
> From: Nikita Kiryanov [mailto:nik...@compulab.co.il]
> Sent: Sunday, June 02, 2013 1:06 PM
> To: Piotr Wilczek
> Cc: u-boot@lists.denx.de; Kyungmin Park
> Subject: Re: [U-Boot] [PATCH] lcd: align bmp header when uncopmressing
> image
> 
> Hello Piotr,
> 
> On 05/31/2013 02:26 PM, Piotr Wilczek wrote:
> > -bmp_image_t *gunzip_bmp(unsigned long addr, unsigned long *lenp)
> > +bmp_image_t *gunzip_bmp(unsigned long addr, unsigned long *lenp,
> > +                   void **alloc_addr)
> >   {
> >     void *dst;
> >     unsigned long len;
> > @@ -60,7 +65,14 @@ bmp_image_t *gunzip_bmp(unsigned long addr,
> unsigned long *lenp)
> >             puts("Error: malloc in gunzip failed!\n");
> >             return NULL;
> >     }
> > -   if (gunzip(dst, CONFIG_SYS_VIDEO_LOGO_MAX_SIZE, (uchar *)addr,
> &len) != 0) {
> > +
> > +   bmp = dst;
> > +
> > +   /* align to 32-bit-aligned-address + 2 */
> > +   if ((unsigned int)bmp % 0x04 != 0x02)
> > +           bmp = (bmp_image_t *)(((unsigned int)dst + 0x02) & ~0x01);
> 
> This is wrong. Suppose that bmp % 4 == 3, then (dst + 2) % 4 == 1, and
> thus ((dst + 2) & ~1) % 4 == 0, which is not an aligned+2 address.
> 
You are right but here I'm aligning a pointer returned by malloc which is
guaranteed to be aligned to 8 bytes. In fact it is sufficient only to add
two bytes.
Anyway, to make the code universal I provide a better alignment method.

> > +
> > +   if (gunzip(bmp, CONFIG_SYS_VIDEO_LOGO_MAX_SIZE, (uchar *)addr,
> &len)
> > +!= 0) {
> >             free(dst);
> >             return NULL;
> >     }
> > @@ -68,8 +80,6 @@ bmp_image_t *gunzip_bmp(unsigned long addr,
> unsigned long *lenp)
> >             puts("Image could be truncated"
> >                             " (increase
> CONFIG_SYS_VIDEO_LOGO_MAX_SIZE)!\n");
> >
> 
> --
> Regards,
> Nikita.

Best regards,
Piotr



_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to