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
14931493 char cbuf[32];
14941494 char *c = cbuf;
14951495 int i;
1496+ int j;
14961497 unsigned long word;
14971498
14981499 memset(cbuf, '\0', sizeof(cbuf));
@@ -1538,25 +1539,9 @@ static void kdb_md_line(const char *fmtstr, unsigned long addr, · 39 unmodified lines
15381539 wc.word = word;
15391540 #define printable_char(c) \
15401541 ({unsigned char __c = c; isascii(__c) && isprint(__c) ? __c : '.'; })
1541− switch (bytesperword) {
1542− case 8:
1542+ for (j = 0; j < bytesperword; j++)
15431543 *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;
15601545 #undef printable_char
15611546 }
15621547 }