[U-Boot] [PATCH] include/image.h: Use explicit function definitions instead of macro trickery

Wolfgang Denk wd at denx.de
Wed Jan 28 22:20:13 CET 2009


Dear Petri Lehtinen,

In message <1233125286-29550-1-git-send-email-petri.lehtinen at inoi.fi> you wrote:
> Signed-off-by: Petri Lehtinen <petri.lehtinen at inoi.fi>
> ---
> 
> 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


More information about the U-Boot mailing list