[U-Boot] [PATCH] part: show efi partition name when print out partition info

Wolfgang Denk wd at denx.de
Wed Sep 7 21:21:54 CEST 2011


Dear Lei Wen,

In message <1315394223-12399-1-git-send-email-leiwen at marvell.com> you wrote:
...
> +static char *print_efiname(gpt_entry *pte)
> +{
> +	static char name[37];

I hate these magic constants where nobody knows where they are coming
from.  Please use the size of the partition_name[] array for reference
instead.

> +	int i;
> +	for (i = 0; i < 37; i++) {

Again, drop this magic constant.  Also note that 37 is actually wrong
here - you are accessing an element beyond the end of partition_name[]

> +		u8 c;
> +		c = pte->partition_name[i] & 0xff;
> +		c = (c && !isprint(c)) ? '!' : c;

Why do you use '!' to mark nonprinting characters?  Most memory dump
tools atc. use '.' instead.

> +		name[i] = c;
> +	}
> +	name[36] = 0;

And again: get rid of this constant.

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
The thing is, as you progress in the Craft,  you'll  learn  there  is
another rule... When you break rules, break 'em good and hard.
                                    - Terry Pratchett, _Wyrd Sisters_


More information about the U-Boot mailing list