Changeset b682f4cb in rtems


Ignore:
Timestamp:
Jul 18, 2017, 11:03:41 AM (2 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
07e1780
Parents:
533ac112
git-author:
Sebastian Huber <sebastian.huber@…> (07/18/17 11:03:41)
git-committer:
Sebastian Huber <sebastian.huber@…> (07/18/17 12:13:48)
Message:

dumpbuf: Simplify rtems_print_buffer()

This avoids an unnecessary use of the floating point unit.

Update #3076.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libmisc/dumpbuf/dumpbuf.c

    r533ac112 rb682f4cb  
    7171}
    7272
     73static char const hexlist[] = "0123456789abcdef";
     74
    7375/**
    7476 * @brief Print \p length bytes from \p buffer, both in hex and ASCII.
     
    8183{
    8284  unsigned int i;
    83   static char line_buffer[ROW_LENGTH] = "";
    84   size_t tmp_len;
    8585
    8686  /* Output the hex value of each byte. */
    8787  for (i = 0; i < length; ++i) {
    88     snprintf(&line_buffer[i * HEX_FMT_LENGTH], HEX_FMT_LENGTH + 1,
    89              "%02x ", buffer[i]);
     88    unsigned char c = buffer[i];
     89
     90    rtems_putc(hexlist[(c >> 4) & 0xf]);
     91    rtems_putc(hexlist[0xf]);
     92    rtems_putc(' ');
    9093  }
    9194
    9295  /* Fill the remaining space with whitespace (if necessary). */
    9396  for (; i < BYTES_PER_ROW; ++i) {
    94     strncat(line_buffer, "   ", HEX_FMT_LENGTH);
     97    rtems_putc(' ');
     98    rtems_putc(' ');
     99    rtems_putc(' ');
    95100  }
    96101
    97102  /* Append a bar. */
    98   strncat(line_buffer, "|", 1);
    99   tmp_len = strnlen(line_buffer, ROW_LENGTH);
     103  rtems_putc('|');
    100104
    101105  /* Now output the ASCII glyphs of printable chars. */
    102106  for (i = 0; i < length; ++i) {
    103     snprintf(&line_buffer[tmp_len + i], ASCII_FMT_LENGTH + 1,
    104              "%c", isprint(buffer[i]) ? buffer[i] : '.');
     107    unsigned char c = buffer[i];
     108
     109    rtems_putc(isprint(c) ? c : '.');
    105110  }
    106111
    107112  /* Fill the remaining space with whitespace (if necessary). */
    108113  for(; i < BYTES_PER_ROW; i++) {
    109     strncat(line_buffer, " ", ASCII_FMT_LENGTH);
     114    rtems_putc(' ');
    110115  }
    111116
    112117  /* Append another bar and print the resulting string. */
    113   printk("%s|\n", line_buffer);
     118  rtems_putc('|');
     119  rtems_putc('\n');
    114120}
Note: See TracChangeset for help on using the changeset viewer.