X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvppinfra%2Fstd-formats.c;h=b771b947e27f6c674c7a0c402ebb066687825f8f;hb=e5d34919b;hp=debf19417919eb7ca3fe9fbba02b76a04778de6a;hpb=e3ea79747a3fb6770842a809b818aaf32e06f02b;p=vpp.git diff --git a/src/vppinfra/std-formats.c b/src/vppinfra/std-formats.c index debf1941791..b771b947e27 100644 --- a/src/vppinfra/std-formats.c +++ b/src/vppinfra/std-formats.c @@ -108,6 +108,22 @@ format_hex_bytes (u8 * s, va_list * va) return s; } +u8 * +format_hex_bytes_no_wrap (u8 * s, va_list * va) +{ + u8 *bytes = va_arg (*va, u8 *); + int n_bytes = va_arg (*va, int); + uword i; + + if (n_bytes == 0) + return s; + + for (i = 0; i < n_bytes; i++) + s = format (s, "%02x", bytes[i]); + + return s; +} + /* Add variable number of spaces. */ u8 * format_white_space (u8 * s, va_list * va) @@ -253,7 +269,7 @@ unformat_memory_size (unformat_input_t * input, va_list * va) } /* Format c identifier: e.g. a_name -> "a name". - Words for both vector names and null terminated c strings. */ + Works for both vector names and null terminated c strings. */ u8 * format_c_identifier (u8 * s, va_list * va) { @@ -313,7 +329,8 @@ format_hexdump (u8 * s, va_list * args) if (vec_len (line_hex)) s = format (s, "%U%05x: %v[%v]", - format_white_space, indent, index, line_hex, line_str); + format_white_space, index ? indent : 0, + index, line_hex, line_str); vec_free (line_hex); vec_free (line_str);