From: Wolfgang Denk Date: Thu, 20 Aug 2009 11:28:29 +0200 Subject: [U-Boot] [PATCH "mkimage" branch] tools/mkimage: fix compiler warnings, use "const" In-Reply-To: <73173D32E9439E4ABB5151606C3E19E202E3915996@SC-VEXCH1.marvell.com> References: <73173D32E9439E4ABB5151606C3E19E202E3915996@SC-VEXCH1.marvell.com> Message-ID: <20090820092829.120A8833DBD2@gemini.denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Dear Prafulla, In message <73173D32E9439E4ABB5151606C3E19E202E3915996@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.