summaryrefslogtreecommitdiff
path: root/util/nvramtool/hexdump.c
diff options
context:
space:
mode:
authorPatrick Georgi <patrick.georgi@secunet.com>2011-01-18 12:14:08 +0000
committerPatrick Georgi <patrick.georgi@coresystems.de>2011-01-18 12:14:08 +0000
commit024ec852c29685549e5167f4b5d9065e80287ee2 (patch)
tree81b5393be08b5a5d037ba61e1f60b5dbe6c5dfe4 /util/nvramtool/hexdump.c
parent2601697c6f70e0200f6f115d6e6e5e5d67fe6101 (diff)
Remove overengineering, part 1/many
Signed-off-by: Patrick Georgi <patrick.georgi@secunet.com> Acked-by: Patrick Georgi <patrick.georgi@secunet.com> git-svn-id: svn://svn.coreboot.org/coreboot/trunk@6267 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'util/nvramtool/hexdump.c')
-rw-r--r--util/nvramtool/hexdump.c41
1 files changed, 5 insertions, 36 deletions
diff --git a/util/nvramtool/hexdump.c b/util/nvramtool/hexdump.c
index 405703fe73..320b4d9f45 100644
--- a/util/nvramtool/hexdump.c
+++ b/util/nvramtool/hexdump.c
@@ -46,8 +46,7 @@
static void addrprint(FILE * outfile, uint64_t address, int width);
static void hexprint(FILE * outfile, unsigned char byte);
static void charprint(FILE * outfile, unsigned char byte,
- unsigned char nonprintable,
- is_printable_fn_t is_printable_fn);
+ unsigned char nonprintable);
/*--------------------------------------------------------------------------
* hexdump
@@ -70,17 +69,11 @@ void hexdump(const void *mem, int bytes, uint64_t addrprint_start,
{
int bytes_left, index, i;
const unsigned char *p;
- is_printable_fn_t is_printable_fn;
/* Quietly return if the caller asks us to do something unreasonable. */
if ((format->bytes_per_line <= 0) || (bytes < 0))
return;
- is_printable_fn = format->is_printable_fn;
-
- if (is_printable_fn == NULL)
- is_printable_fn = default_is_printable_fn;
-
p = (const unsigned char *)mem;
index = 0;
@@ -112,8 +105,7 @@ void hexdump(const void *mem, int bytes, uint64_t addrprint_start,
/* display the bytes as characters */
for (i = 0; i < format->bytes_per_line; i++)
- charprint(outfile, p[index++], format->nonprintable,
- is_printable_fn);
+ charprint(outfile, p[index++], format->nonprintable);
fprintf(outfile, "\n");
}
@@ -148,8 +140,7 @@ void hexdump(const void *mem, int bytes, uint64_t addrprint_start,
/* display bytes for last line as characters */
for (i = 0; i < bytes_left; i++)
- charprint(outfile, p[index++], format->nonprintable,
- is_printable_fn);
+ charprint(outfile, p[index++], format->nonprintable);
/* pad the rest of the character area with spaces */
for (; i < format->bytes_per_line; i++)
@@ -159,25 +150,6 @@ void hexdump(const void *mem, int bytes, uint64_t addrprint_start,
}
/*--------------------------------------------------------------------------
- * default_is_printable_fn
- *
- * Determine whether the input character is printable. The proper behavior
- * for this type of function may be system-dependent. This function takes a
- * conservative approach. If it is not adequate for your purposes, you can
- * write your own.
- *
- * parameters:
- * c: the input character
- *
- * return value:
- * Return 1 if the input character is printable. Otherwise return 0.
- *--------------------------------------------------------------------------*/
-int default_is_printable_fn(unsigned char c)
-{
- return (c >= 0x20) && (c <= 0x7e);
-}
-
-/*--------------------------------------------------------------------------
* addrprint
*
* Display an address as a hexadecimal number.
@@ -245,12 +217,9 @@ static void hexprint(FILE * outfile, unsigned char byte)
* byte: the byte to display
* nonprintable: a substitute character to display if the byte
* represents a nonprintable character
- * is_printable_fn: a function that returns a boolean value indicating
- * whether a given character is printable
*--------------------------------------------------------------------------*/
static void charprint(FILE * outfile, unsigned char byte,
- unsigned char nonprintable,
- is_printable_fn_t is_printable_fn)
+ unsigned char nonprintable)
{
- fprintf(outfile, "%c", is_printable_fn(byte) ? byte : nonprintable);
+ fprintf(outfile, "%c", ((byte >= 0x20) && (byte <= 0x7e)) ? byte : nonprintable);
}