From: Wolfgang Denk Date: Wed, 07 Sep 2011 21:21:54 +0200 Subject: [U-Boot] [PATCH] part: show efi partition name when print out partition info In-Reply-To: <1315394223-12399-1-git-send-email-leiwen@marvell.com> References: <1315394223-12399-1-git-send-email-leiwen@marvell.com> Message-ID: <20110907192154.6C99E140875D@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 Lei Wen, In message <1315394223-12399-1-git-send-email-leiwen@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_