diff --git a/sys/include/od.h b/sys/include/od.h index 8cd2d20159bbb14dea39c23fa4177050dbf20809..d7120659c0b05a4b69be633c92a50a656f585fb3 100644 --- a/sys/include/od.h +++ b/sys/include/od.h @@ -136,7 +136,7 @@ extern "C" { * @param[in] flags Flags as defined in @ref od_flags_address and * @ref od_flags_bytes */ -void od(void *data, size_t data_len, uint8_t width, uint16_t flags); +void od(const void *data, size_t data_len, uint8_t width, uint16_t flags); /** * @brief Dumps memory stored at *data* up to *data_len* in octal, decimal, or @@ -148,7 +148,7 @@ void od(void *data, size_t data_len, uint8_t width, uint16_t flags); * @param[in] width Number of bytes per line. If *width* is 0, * @ref OD_WIDTH_DEFAULT is assumed as a default value. */ -static inline void od_hex_dump(void *data, size_t data_len, uint8_t width) +static inline void od_hex_dump(const void *data, size_t data_len, uint8_t width) { od(data, data_len, width, OD_FLAGS_ADDRESS_HEX | OD_FLAGS_BYTES_HEX | OD_FLAGS_LENGTH_1); } diff --git a/sys/od/od.c b/sys/od/od.c index 21cd1ade8e317ddcd22ebafb59c6a881582a81ee..b49af2996d541b65b130051ef9abd33377911d23 100644 --- a/sys/od/od.c +++ b/sys/od/od.c @@ -178,13 +178,13 @@ static inline void _bytes_format(char *format, uint16_t flags) } } -static void _print_date(void *data, size_t offset, char *format, uint8_t length, +static void _print_date(const void *data, size_t offset, char *format, uint8_t length, uint16_t flags) { switch (length) { case 1: if (flags & OD_FLAGS_BYTES_CHAR) { - switch (((char *)data)[offset]) { + switch (((signed char *)data)[offset]) { case '\0': printf(" \\0"); return; @@ -218,11 +218,11 @@ static void _print_date(void *data, size_t offset, char *format, uint8_t length, return; default: - if (((char *)data)[offset] < 0) { + if (((signed char *)data)[offset] < 0) { printf(" %03o", ((unsigned char *)data)[offset]); return; } - else if (((char *)data)[offset] < 32) { + else if (((signed char *)data)[offset] < 32) { printf(" %03o", ((char *)data)[offset]); return; } @@ -287,7 +287,7 @@ static int _log10(uint8_t a) return ++res; } -void od(void *data, size_t data_len, uint8_t width, uint16_t flags) +void od(const void *data, size_t data_len, uint8_t width, uint16_t flags) { char address_format[5]; uint8_t date_length = _length(flags);