public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Daniel Thompson <daniel.thompson@linaro.org>
To: Douglas Anderson <dianders@chromium.org>
Cc: kgdb-bugreport@lists.sourceforge.net,
	Christophe JAILLET <christophe.jaillet@wanadoo.fr>,
	Jason Wessel <jason.wessel@windriver.com>,
	Thorsten Blum <thorsten.blum@toblux.com>,
	Yuran Pereira <yuran.pereira@hotmail.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 09/13] kdb: Use 'unsigned int' in kdb_md() where appropriate
Date: Tue, 18 Jun 2024 16:26:17 +0100	[thread overview]
Message-ID: <20240618152617.GF11330@aspen.lan> (raw)
In-Reply-To: <20240617173426.9.I95a99321878631c9ed6a520feba65b949f948529@changeid>

On Mon, Jun 17, 2024 at 05:34:43PM -0700, Douglas Anderson wrote:
> Several of the integers in kdb_md() should be marked unsigned. Mark
> them as such. When doing this, we need to add an explicit cast to the
> address masking or it ends up getting truncated down to "int" size.
>
> Signed-off-by: Douglas Anderson <dianders@chromium.org>
> ---
>
>  kernel/debug/kdb/kdb_main.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
> index fcd5292351a7..c064ff093670 100644
> --- a/kernel/debug/kdb/kdb_main.c
> +++ b/kernel/debug/kdb/kdb_main.c
> @@ -1594,8 +1594,8 @@ static void kdb_md_line(const char *fmtstr, unsigned long addr,
>  static int kdb_md(int argc, const char **argv)
>  {
>  	static unsigned long last_addr;
> -	static int last_radix, last_bytesperword, last_repeat;
> -	int radix = 16, mdcount = 8, bytesperword = KDB_WORD_SIZE, repeat = 0;
> +	static unsigned int last_radix, last_bytesperword, last_repeat;
> +	unsigned int radix = 16, mdcount = 8, bytesperword = KDB_WORD_SIZE, repeat = 0;
>  	char fmtchar, fmtstr[64];
>  	unsigned long addr;
>  	unsigned long word;
> @@ -1722,11 +1722,11 @@ static int kdb_md(int argc, const char **argv)
>
>  	/* Round address down modulo BYTESPERWORD */
>
> -	addr &= ~(bytesperword-1);
> +	addr &= ~((unsigned long)bytesperword - 1);

I think the round_down() macro will take care of the cast for you (and
probably render the comment pointless too).

Other than that it looks like a good change.


Daniel.

  reply	other threads:[~2024-06-18 15:26 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-18  0:34 [PATCH 00/13] kdb: Add the ability to read iomapped memory via kdb + clean up "md" commands Douglas Anderson
2024-06-18  0:34 ` [PATCH 01/13] kdb: Get rid of "minlen" for the "md" command Douglas Anderson
2024-06-18  0:34 ` [PATCH 02/13] kdb: Document the various "md" commands better Douglas Anderson
2024-06-18 11:24   ` Daniel Thompson
2024-06-18 14:42     ` Doug Anderson
2024-06-18  0:34 ` [PATCH 03/13] kdb: Use "bool" in "md" implementation where appropriate Douglas Anderson
2024-06-18  0:34 ` [PATCH 04/13] kdb: Drop "offset" and "name" args to kdbgetaddrarg() Douglas Anderson
2024-06-18  0:34 ` [PATCH 05/13] kdb: Separate out "mdr" handling Douglas Anderson
2024-06-18 11:29   ` Daniel Thompson
2024-06-18  0:34 ` [PATCH 06/13] kdb: Remove "mdW" and "mdWcN" handling of "W" == 0 Douglas Anderson
2024-06-18 11:37   ` Daniel Thompson
2024-06-18 14:42     ` Doug Anderson
2024-06-18  0:34 ` [PATCH 07/13] kdb: Tweak "repeat" handling code for "mdW" and "mdWcN" Douglas Anderson
2024-06-18 12:57   ` Daniel Thompson
2024-06-18 14:43     ` Doug Anderson
2024-06-18  0:34 ` [PATCH 08/13] kdb: In kdb_md() make `repeat` and `mdcount` calculations more obvious Douglas Anderson
2024-06-18  0:34 ` [PATCH 09/13] kdb: Use 'unsigned int' in kdb_md() where appropriate Douglas Anderson
2024-06-18 15:26   ` Daniel Thompson [this message]
2024-06-18  0:34 ` [PATCH 10/13] kdb: Replease simple_strtoul() with kstrtouint() in kdb_md() Douglas Anderson
2024-06-18  0:34 ` [PATCH 11/13] kdb: Abstract out parsing for mdWcN Douglas Anderson
2024-06-18 21:02   ` kernel test robot
2024-06-18  0:34 ` [PATCH 12/13] kdb: Add mdpW / mdpWcN commands Douglas Anderson
2024-06-18  0:34 ` [PATCH 13/13] kdb: Add mdi, mdiW / mdiWcN commands to show iomapped memory Douglas Anderson
2024-06-18 15:59   ` Daniel Thompson
2024-06-18 19:33     ` Doug Anderson
2024-06-21 15:43       ` Daniel Thompson
2024-06-21 19:52         ` Doug Anderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240618152617.GF11330@aspen.lan \
    --to=daniel.thompson@linaro.org \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=dianders@chromium.org \
    --cc=jason.wessel@windriver.com \
    --cc=kgdb-bugreport@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=thorsten.blum@toblux.com \
    --cc=yuran.pereira@hotmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox