diff options
author | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2022-05-16 17:37:56 -0700 |
---|---|---|
committer | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2022-05-18 15:35:46 -0700 |
commit | 0247ed333ea9dc0ac914bae68225d5cb3f288f80 (patch) | |
tree | 189257972d73cfb6b60c2535b5eda630827b522c /monitor/display.h | |
parent | f66673878a9f3745c9cb3cfaa85b5b8f99a929d6 (diff) | |
download | bluez-0247ed333ea9dc0ac914bae68225d5cb3f288f80.tar.gz |
monitor: Move print_hex_field to display.h
This moves print_hex_field to display.h and removes the duplicated code
from packet.c and l2cap.c.
Diffstat (limited to 'monitor/display.h')
-rw-r--r-- | monitor/display.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/monitor/display.h b/monitor/display.h index be5739833..5a82f8e6f 100644 --- a/monitor/display.h +++ b/monitor/display.h @@ -76,6 +76,20 @@ static inline uint64_t print_bitfield(int indent, uint64_t val, return mask; } +static inline void print_hex_field(const char *label, const uint8_t *data, + uint8_t len) +{ + char str[len * 2 + 1]; + uint8_t i; + + str[0] = '\0'; + + for (i = 0; i < len; i++) + sprintf(str + (i * 2), "%2.2x", data[i]); + + print_field("%s: %s", label, str); +} + void set_default_pager_num_columns(int num_columns); int num_columns(void); |