Skip to content

Commit 23f88ea

Browse files
committed
Fixed dbgDumpMemory for buffers > 255 bytes
1 parent 88a2b7a commit 23f88ea

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

cores/nRF5/debug.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,15 +177,16 @@ void dbgPrintVersion(void)
177177
void dbgDumpMemory(void const *buf, uint8_t size, uint16_t count, bool printOffset)
178178
{
179179
uint8_t const *buf8 = (uint8_t const *) buf;
180+
181+
uint8_t format_size = 2 * size;
182+
if ( count*size > UINT8_MAX ) format_size *= 2;
183+
if ( count*size > UINT16_MAX ) format_size *= 2;
180184

181185
char format[] = "%00lX";
182-
format[2] += 2*size;
186+
format[2] += format_size;
183187

184188
char offset_fmt[] = "%02lX: ";
185189

186-
if ( count*size > UINT8_MAX ) format[2] *= 2;
187-
if ( count*size > UINT16_MAX ) format[2] *= 2;
188-
189190
const uint8_t item_per_line = 16 / size;
190191

191192
for(int i=0; i<count; i++)

0 commit comments

Comments
 (0)