DDF: guid_str: more readable output

Print ASCII characters as ASCII

Signed-off-by: NeilBrown <neilb@suse.de>
This commit is contained in:
mwilck@arcor.de 2013-07-08 23:50:46 +02:00 committed by NeilBrown
parent 6a7e7ecce9
commit 4a03cbd10b
1 changed files with 7 additions and 2 deletions

View File

@ -1301,8 +1301,13 @@ static const char *guid_str(const char *guid)
static char buf[DDF_GUID_LEN*2+1];
int i;
char *p = buf;
for (i = 0; i < DDF_GUID_LEN; i++)
p += sprintf(p, "%02x", (unsigned char)guid[i]);
for (i = 0; i < DDF_GUID_LEN; i++) {
unsigned char c = guid[i];
if (c >= 32 && c < 127)
p += sprintf(p, "%c", c);
else
p += sprintf(p, "%02x", c);
}
*p = '\0';
return (const char *) buf;
}