qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <richard.henderson@linaro.org>
To: "Philippe Mathieu-Daudé" <philmd@linaro.org>, qemu-devel@nongnu.org
Cc: qemu-riscv@nongnu.org, qemu-arm@nongnu.org,
	Paolo Bonzini <pbonzini@redhat.com>,
	Marcelo Tosatti <mtosatti@redhat.com>,
	kvm@vger.kernel.org
Subject: Re: [PATCH 9/9] target/i386: Replace sprintf() by snprintf()
Date: Thu, 11 Apr 2024 14:46:11 -0700	[thread overview]
Message-ID: <5245b4a6-7246-456d-8be0-91fef19b8367@linaro.org> (raw)
In-Reply-To: <20240411104340.6617-10-philmd@linaro.org>

On 4/11/24 03:43, Philippe Mathieu-Daudé 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>
> ---
>   target/i386/kvm/kvm.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c
> index e68cbe9293..a46d1426bf 100644
> --- a/target/i386/kvm/kvm.c
> +++ b/target/i386/kvm/kvm.c
> @@ -5335,7 +5335,8 @@ int kvm_arch_handle_exit(CPUState *cs, struct kvm_run *run)
>       case KVM_EXIT_NOTIFY:
>           ctx_invalid = !!(run->notify.flags & KVM_NOTIFY_CONTEXT_INVALID);
>           state = KVM_STATE(current_accel());
> -        sprintf(str, "Encounter a notify exit with %svalid context in"
> +        snprintf(str, sizeof(str),
> +                     "Encounter a notify exit with %svalid context in"
>                        " guest. There can be possible misbehaves in guest."
>                        " Please have a look.", ctx_invalid ? "in" : "");
>           if (ctx_invalid ||

In the larger context,

>         if (ctx_invalid ||
>             state->notify_vmexit == NOTIFY_VMEXIT_OPTION_INTERNAL_ERROR) {
>             warn_report("KVM internal error: %s", str);
>             ret = -1;
>         } else {
>             warn_report_once("KVM: %s", str);
>             ret = 0;
>         }

so there's really no need to sprintf into a buffer at all -- just pass it all to 
warn_report_*.

The English text could use some improvement as well.  :-)


r~


      parent reply	other threads:[~2024-04-11 21:46 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
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 [this message]

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=5245b4a6-7246-456d-8be0-91fef19b8367@linaro.org \
    --to=richard.henderson@linaro.org \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    --cc=pbonzini@redhat.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).