public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Wolfgang Denk <wd@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH "mkimage" branch] tools/mkimage: fix compiler warnings, use "const"
Date: Thu, 20 Aug 2009 11:28:29 +0200	[thread overview]
Message-ID: <20090820092829.120A8833DBD2@gemini.denx.de> (raw)
In-Reply-To: <73173D32E9439E4ABB5151606C3E19E202E3915996@SC-VEXCH1.marvell.com>

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.

  reply	other threads:[~2009-08-20  9:28 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-19  9:54 [U-Boot] [PATCH "mkimage" branch] tools/mkimage: fix compiler warnings, use "const" Wolfgang Denk
2009-08-20  8:37 ` Prafulla Wadaskar
2009-08-20  9:28   ` Wolfgang Denk [this message]
2009-08-20  9:50     ` Prafulla Wadaskar
2009-09-10  8:39 ` Wolfgang Denk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090820092829.120A8833DBD2@gemini.denx.de \
    --to=wd@denx.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox