History

kdb: kdb_main: refactor code in kdb_md_line

Replace the whole switch statement with a for loop. This makes the code clearer and easy to read. This also addresses the following Coverity warnings: Addresses-Coverity-ID: 115090 ("Missing break in switch") Addresses-Coverity-ID: 115091 ("Missing break in switch") Addresses-Coverity-ID: 114700 ("Missing break in switch")

Gustavo A. R. Silva committed 8 years ago

Commit 9eb62f01 parent c2b94c71 file · +3 −18Browse files

Showing the changes to kernel/debug (1 of 1 file). Show all

Unified · Split

kernel/debug/kdb/kdb_main.c+3−18
@@ -1493,6 +1493,7 @@ static void kdb_md_line(const char *fmtstr, unsigned long addr, · 1492 unmodified lines
1493 char cbuf[32];1493 char cbuf[32];
1494 char *c = cbuf;1494 char *c = cbuf;
1495 int i;1495 int i;
1496 int j;
1496 unsigned long word;1497 unsigned long word;
1497 1498
1498 memset(cbuf, '\0', sizeof(cbuf));1499 memset(cbuf, '\0', sizeof(cbuf));
@@ -1538,25 +1539,9 @@ static void kdb_md_line(const char *fmtstr, unsigned long addr, · 39 unmodified lines
1538 wc.word = word;1539 wc.word = word;
1539#define printable_char(c) \1540#define printable_char(c) \
1540 ({unsigned char __c = c; isascii(__c) && isprint(__c) ? __c : '.'; })1541 ({unsigned char __c = c; isascii(__c) && isprint(__c) ? __c : '.'; })
1541 switch (bytesperword) {1542 for (j = 0; j < bytesperword; j++)
1542 case 8:
1543 *c++ = printable_char(*cp++);1543 *c++ = printable_char(*cp++);
1544 *c++ = printable_char(*cp++);1544 addr += bytesperword;
1545 *c++ = printable_char(*cp++);
1546 *c++ = printable_char(*cp++);
1547 addr += 4;
1548 case 4:
1549 *c++ = printable_char(*cp++);
1550 *c++ = printable_char(*cp++);
1551 addr += 2;
1552 case 2:
1553 *c++ = printable_char(*cp++);
1554 addr++;
1555 case 1:
1556 *c++ = printable_char(*cp++);
1557 addr++;
1558 break;
1559 }
1560#undef printable_char1545#undef printable_char
1561 }1546 }
1562 }1547 }