Dear Piotr Wilczek, In message <000701ce6025$173886c0$45a99440$%wilc...@samsung.com> you wrote: > > > > + /* 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.
Such assumptions are black magic at best. Please always consider the mentalk welfare of your follow programmers who for example might change this into a character array (say, a buffer on the stack) and suddenly experience mysetrious crashes. Please always write code such that it is NOT based on non-obvious requirements. > Anyway, to make the code universal I provide a better alignment method. Thanks. Best regards, Wolfgang Denk -- DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de "God is a comedian playing to an audience too afraid to laugh." - Voltaire _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot