[U-Boot] [PATCH "mkimage" branch] tools/mkimage: fix compiler warnings, use "const"
Wolfgang Denk
wd at denx.de
Thu Aug 20 11:28:29 CEST 2009
Dear Prafulla,
In message <73173D32E9439E4ABB5151606C3E19E202E3915996 at SC-VEXCH1.marvell.com> you wrote:
>
> > This fixes some compiler warnings:
> > tools/default_image.c:141: warning: initialization from
> > incompatible pointer type
> > tools/fit_image.c:202: warning: initialization from
> > incompatible pointer type
> > and changes to code to use "const" attributes in a few places where
> > it's appropriate.
>
> 99% of the changes in this patch is to add const attributes.
Yes, indeed.
> Can you pls explain here- how useful it is to add const.
Well, adding "const" where appropriate is definitely a good thing, as
it const augments data-hiding and encapsulation and allows the
compiler to check for (and prevent!) unintended modification of data
structures, i. e. for programming errors. Also, it helps the compiler
for better optimization.
> Or do it make more sense just to fix the warnings in respective functions?
> I have posted a patch for the same
I did not see any patch form you addressing these warnings?
My "const"-adding patch was the more or less direct result of getting
rid of the warnings without using additional type casts.
I think using const is a good thing. I am aware that it sometimes
becomes painful, and some consider it a waste of time.
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: wd at denx.de
God made machine language; all the rest is the work of man.
More information about the U-Boot
mailing list