[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 4/9] linux-user/flatload: Replace sprintf() by snprintf()
From: |
Peter Maydell |
Subject: |
Re: [PATCH 4/9] linux-user/flatload: Replace sprintf() by snprintf() |
Date: |
Thu, 11 Apr 2024 12:40:20 +0100 |
On Thu, 11 Apr 2024 at 11:44, 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>
> ---
> linux-user/flatload.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/linux-user/flatload.c b/linux-user/flatload.c
> index 5b62aa0a2b..b0f04af4b6 100644
> --- a/linux-user/flatload.c
> +++ b/linux-user/flatload.c
> @@ -692,7 +692,7 @@ static int load_flat_shared_library(int id, struct
> lib_info *libs)
> char buf[16];
>
> /* Create the file name */
> - sprintf(buf, "/lib/lib%d.so", id);
> + snprintf(buf, sizeofbuf), "/lib/lib%d.so", id);
Indentation has gone wrong, and another missing '('.
Looking at that, I notice that this function is actually
dead code -- it's in code that is only compiled and called
if CONFIG_BINFMT_SHARED_FLAT is defined, and if you try to
define that you will hit the "#error needs checking" in the
calc_reloc() function. It seems to have been like this since
the flatload support was added in 2006.
So I think we should remove the dead code -- I'll send a patch.
thanks
-- PMM
- [PATCH 1/9] disas/m68k: Replace sprintf() by snprintf(), (continued)
- [PATCH 1/9] disas/m68k: Replace sprintf() by snprintf(), Philippe Mathieu-Daudé, 2024/04/11
- [PATCH 2/9] disas/microblaze: Replace sprintf() by snprintf(), Philippe Mathieu-Daudé, 2024/04/11
- [PATCH 3/9] disas/riscv: Replace sprintf() by snprintf(), Philippe Mathieu-Daudé, 2024/04/11
- [PATCH 4/9] linux-user/flatload: Replace sprintf() by snprintf(), Philippe Mathieu-Daudé, 2024/04/11
- Re: [PATCH 4/9] linux-user/flatload: Replace sprintf() by snprintf(),
Peter Maydell <=
- [PATCH 5/9] hw/misc/imx: Replace sprintf() by snprintf(), Philippe Mathieu-Daudé, 2024/04/11
- [PATCH 6/9] hw/net/rocker: Replace sprintf() by snprintf(), Philippe Mathieu-Daudé, 2024/04/11
- [PATCH 7/9] hw/riscv/virt: Replace sprintf() by snprintf(), Philippe Mathieu-Daudé, 2024/04/11
- [PATCH 8/9] target/arm: Replace sprintf() by snprintf(), Philippe Mathieu-Daudé, 2024/04/11