qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
To: "Philippe Mathieu-Daudé" <philmd@linaro.org>
Cc: qemu-devel@nongnu.org, qemu-riscv@nongnu.org, qemu-arm@nongnu.org
Subject: Re: [PATCH 2/9] disas/microblaze: Replace sprintf() by snprintf()
Date: Thu, 11 Apr 2024 14:56:53 +0200	[thread overview]
Message-ID: <CAJy5ezoBzyRJSwqyxGnBqm968ef4zjBaPVdbBKeS+tVn8SY4rQ@mail.gmail.com> (raw)
In-Reply-To: <20240411104340.6617-3-philmd@linaro.org>

On Thu, Apr 11, 2024 at 12:43 PM Philippe Mathieu-Daudé
<philmd@linaro.org> wrote:
>
> sprintf() is deprecated on Darwin since macOS 13.0 / XCode 14.1,
> resulting in painful developper experience. Use snprintf() instead.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>

Reviewed-by: Edgar E. Iglesias <edgar.iglesias@amd.com>


> ---
>  disas/microblaze.c | 25 ++++++++++++++++---------
>  1 file changed, 16 insertions(+), 9 deletions(-)
>
> diff --git a/disas/microblaze.c b/disas/microblaze.c
> index 0b89b9c4fa..49a4c0fd40 100644
> --- a/disas/microblaze.c
> +++ b/disas/microblaze.c
> @@ -600,7 +600,8 @@ static char *
>  get_field (long instr, long mask, unsigned short low)
>  {
>    char tmpstr[25];
> -  sprintf(tmpstr, "%s%d", register_prefix, (int)((instr & mask) >> low));
> +  snprintf(tmpstr, sizeof(tmpstr), "%s%d", register_prefix,
> +           (int)((instr & mask) >> low));
>    return(strdup(tmpstr));
>  }
>
> @@ -608,7 +609,8 @@ static char *
>  get_field_imm (long instr)
>  {
>    char tmpstr[25];
> -  sprintf(tmpstr, "%d", (short)((instr & IMM_MASK) >> IMM_LOW));
> +  snprintf(tmpstr, sizeof(tmpstr), "%d",
> +           (short)((instr & IMM_MASK) >> IMM_LOW));
>    return(strdup(tmpstr));
>  }
>
> @@ -616,7 +618,8 @@ static char *
>  get_field_imm5 (long instr)
>  {
>    char tmpstr[25];
> -  sprintf(tmpstr, "%d", (short)((instr & IMM5_MASK) >> IMM_LOW));
> +  snprintf(tmpstr, sizeof(tmpstr), "%d",
> +           (short)((instr & IMM5_MASK) >> IMM_LOW));
>    return(strdup(tmpstr));
>  }
>
> @@ -624,7 +627,8 @@ static char *
>  get_field_rfsl (long instr)
>  {
>    char tmpstr[25];
> -  sprintf(tmpstr, "%s%d", fsl_register_prefix, (short)((instr & RFSL_MASK) >> IMM_LOW));
> +  snprintf(tmpstr, sizeof(tmpstr), "%s%d", fsl_register_prefix,
> +           (short)((instr & RFSL_MASK) >> IMM_LOW));
>    return(strdup(tmpstr));
>  }
>
> @@ -632,7 +636,8 @@ static char *
>  get_field_imm15 (long instr)
>  {
>    char tmpstr[25];
> -  sprintf(tmpstr, "%d", (short)((instr & IMM15_MASK) >> IMM_LOW));
> +  snprintf(tmpstr, sizeof(tmpstr), "%d",
> +           (short)((instr & IMM15_MASK) >> IMM_LOW));
>    return(strdup(tmpstr));
>  }
>
> @@ -641,7 +646,8 @@ static char *
>  get_field_unsigned_imm (long instr)
>  {
>    char tmpstr[25];
> -  sprintf(tmpstr, "%d", (int)((instr & IMM_MASK) >> IMM_LOW));
> +  snprintf(tmpstr, sizeof(tmpstr), "%d",
> +           (int)((instr & IMM_MASK) >> IMM_LOW));
>    return(strdup(tmpstr));
>  }
>  #endif
> @@ -653,7 +659,8 @@ get_field_unsigned_imm (long instr)
>    {
>    char tmpstr[25];
>
> -  sprintf(tmpstr, "%s%s", register_prefix, (((instr & IMM_MASK) >> IMM_LOW) & REG_MSR_MASK) == 0 ? "pc" : "msr");
> +  snprintf(tmpstr, sizeof(tmpstr), "%s%s", register_prefix,
> +          (((instr & IMM_MASK) >> IMM_LOW) & REG_MSR_MASK) == 0 ? "pc" : "msr");
>
>    return(strdup(tmpstr));
>    }
> @@ -709,7 +716,7 @@ get_field_special(long instr, const struct op_code_struct *op)
>     default :
>       {
>         if ( ((((instr & IMM_MASK) >> IMM_LOW) ^ op->immval_mask) & 0xE000) == REG_PVR_MASK) {
> -         sprintf(tmpstr, "%s%u", pvr_register_prefix,
> +          snprintf(tmpstr, sizeof(tmpstr), "%s%u", pvr_register_prefix,
>                   (unsigned short)(((instr & IMM_MASK) >> IMM_LOW) ^
>                                    op->immval_mask) ^ REG_PVR_MASK);
>          return(strdup(tmpstr));
> @@ -720,7 +727,7 @@ get_field_special(long instr, const struct op_code_struct *op)
>       break;
>     }
>
> -   sprintf(tmpstr, "%s%s", register_prefix, spr);
> +   snprintf(tmpstr, sizeof(tmpstr), "%s%s", register_prefix, spr);
>     return(strdup(tmpstr));
>  }
>
> --
> 2.41.0
>


  reply	other threads:[~2024-04-11 12:58 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-11 10:43 [PATCH 0/9] misc: Replace sprintf() by snprintf() due to macOS deprecation Philippe Mathieu-Daudé
2024-04-11 10:43 ` [PATCH 1/9] disas/m68k: Replace sprintf() by snprintf() Philippe Mathieu-Daudé
2024-04-11 12:01   ` Peter Maydell
2024-04-11 21:01   ` Richard Henderson
2024-04-11 10:43 ` [PATCH 2/9] disas/microblaze: " Philippe Mathieu-Daudé
2024-04-11 12:56   ` Edgar E. Iglesias [this message]
2024-04-11 21:03   ` Richard Henderson
2024-04-11 10:43 ` [PATCH 3/9] disas/riscv: " Philippe Mathieu-Daudé
2024-04-11 12:00   ` Peter Maydell
2024-04-11 21:12   ` Richard Henderson
2024-04-11 10:43 ` [PATCH 4/9] linux-user/flatload: " Philippe Mathieu-Daudé
2024-04-11 11:40   ` Peter Maydell
2024-04-11 10:43 ` [PATCH 5/9] hw/misc/imx: " Philippe Mathieu-Daudé
2024-04-11 10:46   ` Peter Maydell
2024-04-11 10:43 ` [PATCH 6/9] hw/net/rocker: " Philippe Mathieu-Daudé
2024-04-11 11:30   ` Peter Maydell
2024-04-11 21:22     ` Philippe Mathieu-Daudé
2024-04-11 10:43 ` [PATCH 7/9] hw/riscv/virt: " Philippe Mathieu-Daudé
2024-04-11 21:29   ` Richard Henderson
2024-04-11 10:43 ` [PATCH 8/9] target/arm: " Philippe Mathieu-Daudé
2024-04-11 11:32   ` Peter Maydell
2024-04-11 21:29   ` Richard Henderson
2024-04-11 10:43 ` [PATCH 9/9] target/i386: " Philippe Mathieu-Daudé
2024-04-11 11:59   ` Peter Maydell
2024-04-11 21:46   ` Richard Henderson

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=CAJy5ezoBzyRJSwqyxGnBqm968ef4zjBaPVdbBKeS+tVn8SY4rQ@mail.gmail.com \
    --to=edgar.iglesias@gmail.com \
    --cc=philmd@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-riscv@nongnu.org \
    /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;
as well as URLs for NNTP newsgroup(s).