[U-Boot] [PATCH v2 1/3] image: Make image_get_fdt work like image_get_{ram_disk, kernel}

Wolfgang Denk wd at denx.de
Tue Nov 8 17:06:56 CET 2011


Dear Stephen Warren,

In message <1320164902-24190-1-git-send-email-swarren at nvidia.com> you wrote:
> image_get_ram_disk() and image_get_kernel() perform operations in a
> consistent order. Modify image_get_fdt() to do things the same way.
> This allows a later change to insert some image header manipulations
> into these three functions in a consistent fashion.
> 
> v2: New patch
> 
> Signed-off-by: Stephen Warren <swarren at nvidia.com>
> ---
>  common/image.c |    9 +++++++--
>  1 files changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/common/image.c b/common/image.c
> index 555d9d9..b773505 100644
> --- a/common/image.c
> +++ b/common/image.c
> @@ -1131,14 +1131,19 @@ static const image_header_t *image_get_fdt(ulong fdt_addr)
>  {
>  	const image_header_t *fdt_hdr = (const image_header_t *)fdt_addr;
>  
> -	image_print_contents(fdt_hdr);
> +	if (!image_check_magic(fdt_hdr)) {
> +		fdt_error("fdt header bad magic number\n");
> +		return NULL;
> +	}
>  
> -	puts("   Verifying Checksum ... ");
>  	if (!image_check_hcrc(fdt_hdr)) {
>  		fdt_error("fdt header checksum invalid");
>  		return NULL;
>  	}
>  
> +	image_print_contents(fdt_hdr);
> +
> +	puts("   Verifying Checksum ... ");
>  	if (!image_check_dcrc(fdt_hdr)) {
>  		fdt_error("fdt checksum invalid");
>  		return NULL;

The rule in U-Boot when generating output is to print a message
before you start an action, and then either print an OK or an error
message.  The reason for this is debug support: if neither an OK nor
an error comes you know that the test somehow crashed.

Here this principle is violated as image_check_magic() and
image_check_hcrc() will run without being announced.

Please move the output so we get a message printed before starting to
perform the actual tests.

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
Old programmers never die, they just branch to a new address.


More information about the U-Boot mailing list