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")
Showing the changes to kernel/debug (1 of 1 file). Show all
Unified · Split
| @@ -1493,6 +1493,7 @@ static void kdb_md_line(const char *fmtstr, unsigned long addr, · 1492 unmodified lines | ||
| 1493 | 1493 | char cbuf[32]; |
| 1494 | 1494 | char *c = cbuf; |
| 1495 | 1495 | int i; |
| 1496 | + int j; | |
| 1496 | 1497 | unsigned long word; |
| 1497 | 1498 | |
| 1498 | 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 | 1539 | wc.word = word; |
| 1539 | 1540 | #define printable_char(c) \ |
| 1540 | 1541 | ({unsigned char __c = c; isascii(__c) && isprint(__c) ? __c : '.'; }) |
| 1541 | − switch (bytesperword) { | |
| 1542 | − case 8: | |
| 1542 | + for (j = 0; j < bytesperword; j++) | |
| 1543 | 1543 | *c++ = printable_char(*cp++); |
| 1544 | − *c++ = printable_char(*cp++); | |
| 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 | − } | |
| 1544 | + addr += bytesperword; | |
| 1560 | 1545 | #undef printable_char |
| 1561 | 1546 | } |
| 1562 | 1547 | } |