Changeset 24b07ac4 in mainline


Ignore:
Timestamp:
2011-01-29T00:04:28Z (14 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
b3258ad
Parents:
5935fe4c
Message:

More flexible buffer dump

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/uhci/uhci_struct/transfer_descriptor.c

    r5935fe4c r24b07ac4  
     1#include <stdio.h>
    12#include "transfer_descriptor.h"
     3
     4#define BUFFER_LEN 10
     5
     6static void buffer_to_str(char *str, size_t str_size,
     7    uint8_t *buffer, size_t buffer_size)
     8{
     9        if (buffer_size == 0) {
     10                *str = 0;
     11                return;
     12        }
     13        while (str_size >= 4) {
     14                snprintf(str, 4, " %02X", (int) *buffer);
     15                str += 3;
     16                str_size -= 3;
     17                buffer++;
     18                buffer_size--;
     19                if (buffer_size == 0) {
     20                        break;
     21                }
     22        }
     23}
    224
    325void transfer_descriptor_init(transfer_descriptor_t *instance,
     
    3254          buffer, instance->buffer_ptr);
    3355
    34         char * buff = buffer;
    35 
    36         uhci_print_verbose("Buffer dump(8B): %x %x %x %x %x %x %x %x.\n",
    37           buff[0], buff[1], buff[2], buff[3], buff[4], buff[5], buff[6], buff[7]);
     56        char buffer_dump[BUFFER_LEN];
     57        buffer_to_str(buffer_dump, BUFFER_LEN, buffer, size);
     58        uhci_print_verbose("Buffer dump (%zuB): %s.\n", size, buffer_dump);
    3859
    3960        instance->next_va = NULL;
Note: See TracChangeset for help on using the changeset viewer.