diff options
| author | Gustavo A. R. Silva <gustavo@embeddedor.com> | 2018-08-16 10:01:41 -0400 |
|---|---|---|
| committer | Daniel Thompson <daniel.thompson@linaro.org> | 2018-11-13 15:37:53 -0500 |
| commit | 9eb62f0e1bc70ebc9b15837a0c4e8f12a7b910cb (patch) | |
| tree | 42a78bb2b7a3e751c34c07c34b9cbc8dad128d48 /kernel/debug | |
| parent | c2b94c72d93d0929f48157eef128c4f9d2e603ce (diff) | |
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")
Suggested-by: Daniel Thompson <daniel.thompson@linaro.org>
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
[daniel.thompson@linaro.org: Tiny grammar change in description]
Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org>
Diffstat (limited to 'kernel/debug')
| -rw-r--r-- | kernel/debug/kdb/kdb_main.c | 21 |
1 files changed, 3 insertions, 18 deletions
diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c index 959242084b40..d72b32c66f7d 100644 --- a/kernel/debug/kdb/kdb_main.c +++ b/kernel/debug/kdb/kdb_main.c | |||
| @@ -1493,6 +1493,7 @@ static void kdb_md_line(const char *fmtstr, unsigned long addr, | |||
| 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, | |||
| 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_char | 1545 | #undef printable_char |
| 1561 | } | 1546 | } |
| 1562 | } | 1547 | } |
