Re: [PATCH 06/13] kdb: Remove "mdW" and "mdWcN" handling of "W" == 0
From: Daniel Thompson
Date: Tue Jun 18 2024 - 07:54:35 EST
On Mon, Jun 17, 2024 at 05:34:40PM -0700, Douglas Anderson wrote:
> The "mdW" and "mdWcN" generally lets the user control more carefully
> what word size we display memory in and exactly how many words should
> be displayed. Specifically, "md4" says to display memory w/ 4
> bytes-per word and "md4c6" says to display 6 words of memory w/
> 4-bytes-per word.
>
> The kdb "md" implementation has a special rule for when "W" is 0. In
> this case:
> * If you run with "W" == 0 and you've never run a kdb "md" command
> this reboot then it will pick 4 bytes-per-word, ignoring the normal
> default from the environment.
> * If you run with "W" == 0 and you've run a kdb "md" command this
> reboot then it will pick up the bytes per word of the last command.
>
> As an example:
> [1]kdb> md2 0xffffff80c8e2b280 1
> 0xffffff80c8e2b280 0200 0000 0000 0000 e000 8235 0000 0000 ...
> [1]kdb> md0 0xffffff80c8e2b280 1
> 0xffffff80c8e2b280 0200 0000 0000 0000 e000 8235 0000 0000 ...
> [1]kdb> md 0xffffff80c8e2b280 1
> 0xffffff80c8e2b280 0000000000000200 000000008235e000 ...
> [1]kdb> md0 0xffffff80c8e2b280 1
> 0xffffff80c8e2b280 0000000000000200 000000008235e000 ...
>
> This doesn't seem like particularly useful behavior and adds a bunch
> of complexity to the arg parsing. Remove it.
>
> Signed-off-by: Douglas Anderson <dianders@xxxxxxxxxxxx>
> ---
>
> kernel/debug/kdb/kdb_main.c | 5 -----
> 1 file changed, 5 deletions(-)
>
> diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
> index c013b014a7d3..700b4e355545 100644
> --- a/kernel/debug/kdb/kdb_main.c
> +++ b/kernel/debug/kdb/kdb_main.c
> @@ -1611,11 +1611,6 @@ static int kdb_md(int argc, const char **argv)
>
> if (isdigit(argv[0][2])) {
> bytesperword = (int)(argv[0][2] - '0');
> - if (bytesperword == 0) {
> - bytesperword = last_bytesperword;
> - if (bytesperword == 0)
> - bytesperword = 4;
> - }
> last_bytesperword = bytesperword;
> repeat = mdcount * 16 / bytesperword;
Isn't this now a divide-by-zero?
Daniel.