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 <diand...@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.


_______________________________________________
Kgdb-bugreport mailing list
Kgdb-bugreport@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kgdb-bugreport

Reply via email to