From: Wolfgang Denk Date: Wed, 28 Jan 2009 22:20:13 +0100 Subject: [U-Boot] [PATCH] include/image.h: Use explicit function definitions instead of macro trickery In-Reply-To: <1233125286-29550-1-git-send-email-petri.lehtinen@inoi.fi> References: <1233125286-29550-1-git-send-email-petri.lehtinen@inoi.fi> Message-ID: <20090128212013.86C72832E416@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 Petri Lehtinen, In message <1233125286-29550-1-git-send-email-petri.lehtinen@inoi.fi> you wrote: > Signed-off-by: Petri Lehtinen > --- > > I got frustrated while grepping through the sources, trying to find > the definitions of these functions. Thinking back, the obvious place > to look in the first place would of course have been include/image.h, > but it didn't even cross my mind that there could be some macro > trickery behind these functions. > > Anyway, I think that explicit is better than implicit and that this > kind of macro usage is ugly. I am not really sure, but I tend to leave the code as it was. > -#define image_get_hdr_l(f) \ > - static inline uint32_t image_get_##f(image_header_t *hdr) \ > - { \ > - return uimage_to_cpu (hdr->ih_##f); \ > - } > -image_get_hdr_l (magic); > -image_get_hdr_l (hcrc); > -image_get_hdr_l (time); > -image_get_hdr_l (size); > -image_get_hdr_l (load); > -image_get_hdr_l (ep); > -image_get_hdr_l (dcrc); The macro here has the advantages of being compact, and that you need to change one location only to get a consistent set of function declarations. 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 There are two ways of constructing a software design. One way is to make it so simple that there are obviously no deficiencies and the other is to make it so complicated that there are no obvious defi- ciencies. - Charles Anthony Richard Hoare