Skip to content

Commit 6dbdf07

Browse files
committed
Tidy debug_dump header formatting
Reformatted `debug_dump.h` to use the compact brace/style conventions (namespace/function/loop/if blocks) for consistency. Also changed the `NDEBUG` no-op `Dump` declaration from `inline` to `static inline`, keeping it header-safe with internal linkage in release builds.
1 parent ec5f8e6 commit 6dbdf07

1 file changed

Lines changed: 14 additions & 28 deletions

File tree

common/include/firmware/debug/debug_dump.h

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -31,41 +31,34 @@
3131
#include <ctype.h>
3232

3333
#if defined(H3)
34-
namespace uart0
35-
{
34+
namespace uart0 {
3635
int Printf(const char* fmt, ...);
3736
}
3837
#define printf uart0::Printf // NOLINT
3938
#endif
4039

41-
namespace debug
42-
{
43-
namespace dump
44-
{
40+
namespace debug {
41+
namespace dump {
4542
inline constexpr uint32_t kCharsPerLine = 16;
4643
}
4744
#ifdef NDEBUG
48-
inline void Dump([[maybe_unused]] const void* data, [[maybe_unused]] uint32_t size) {}
45+
static inline void Dump([[maybe_unused]] const void* data, [[maybe_unused]] uint32_t size) {}
4946
#else
50-
inline void Dump(const void* data, uint32_t size)
51-
{
47+
inline void Dump(const void* data, uint32_t size) {
5248
uint32_t chars = 0;
5349
const auto* p = reinterpret_cast<const uint8_t*>(data);
5450

5551
printf("%p:%d\n", data, size);
5652

57-
do
58-
{
53+
do {
5954
uint32_t chars_this_line = 0;
6055

6156
printf("%04x ", chars);
6257

6358
const auto* q = p;
6459

65-
while ((chars_this_line < dump::kCharsPerLine) && (chars < size))
66-
{
67-
if (chars_this_line % 8 == 0)
68-
{
60+
while ((chars_this_line < dump::kCharsPerLine) && (chars < size)) {
61+
if (chars_this_line % 8 == 0) {
6962
printf(" ");
7063
}
7164

@@ -78,31 +71,24 @@ inline void Dump(const void* data, uint32_t size)
7871

7972
auto chars_dot_line = chars_this_line;
8073

81-
for (; chars_this_line < dump::kCharsPerLine; chars_this_line++)
82-
{
83-
if (chars_this_line % 8 == 0)
84-
{
74+
for (; chars_this_line < dump::kCharsPerLine; chars_this_line++) {
75+
if (chars_this_line % 8 == 0) {
8576
printf(" ");
8677
}
8778
printf(" ");
8879
}
8980

9081
chars_this_line = 0;
9182

92-
while (chars_this_line < chars_dot_line)
93-
{
94-
if (chars_this_line % 8 == 0)
95-
{
83+
while (chars_this_line < chars_dot_line) {
84+
if (chars_this_line % 8 == 0) {
9685
printf(" ");
9786
}
9887

9988
int ch = *q;
100-
if (isprint(ch))
101-
{
89+
if (isprint(ch)) {
10290
printf("%c", ch);
103-
}
104-
else
105-
{
91+
} else {
10692
printf(".");
10793
}
10894

0 commit comments

Comments
 (0)