qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Laurent Vivier" <laurent@vivier.eu>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: [PATCH 1/2] disas/m68k: Replace sprintf() by snprintf()
Date: Thu, 11 Apr 2024 23:39:32 +0200	[thread overview]
Message-ID: <20240411213933.36548-2-philmd@linaro.org> (raw)
In-Reply-To: <20240411213933.36548-1-philmd@linaro.org>

sprintf() is deprecated on Darwin since macOS 13.0 / XCode 14.1,
resulting in painful developper experience.

Inline sprintf_vma() and use snprintf() instead of sprintf(),
silencing the following warning:

  [38/244] Compiling C object libcommon.fa.p/disas_m68k.c.o
  disas/m68k.c:977:7: warning: 'sprintf' is deprecated:
    This function is provided for compatibility reasons only.
    Due to security concerns inherent in the design of sprintf(3),
    it is highly recommended that you use snprintf(3) instead.
    [-Wdeprecated-declarations]
      sprintf_vma (buf, disp);
      ^

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 include/disas/dis-asm.h | 2 --
 disas/m68k.c            | 4 ++--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/include/disas/dis-asm.h b/include/disas/dis-asm.h
index b26867b641..1d8a4ce9a1 100644
--- a/include/disas/dis-asm.h
+++ b/include/disas/dis-asm.h
@@ -15,8 +15,6 @@ typedef void *PTR;
 typedef uint64_t bfd_vma;
 typedef int64_t bfd_signed_vma;
 typedef uint8_t bfd_byte;
-#define sprintf_vma(s,x) sprintf (s, "%0" PRIx64, x)
-#define snprintf_vma(s,ss,x) snprintf (s, ss, "%0" PRIx64, x)
 
 #define BFD64
 
diff --git a/disas/m68k.c b/disas/m68k.c
index 800b4145ac..e8e61c7a4e 100644
--- a/disas/m68k.c
+++ b/disas/m68k.c
@@ -974,7 +974,7 @@ print_base (int regno, bfd_vma disp, disassemble_info *info)
       else
 	(*info->fprintf_func) (info->stream, "%s@(", reg_names[regno]);
 
-      sprintf_vma (buf, disp);
+      snprintf(buf, sizeof(buf), "%0" PRIx64, disp);
       (*info->fprintf_func) (info->stream, "%s", buf);
     }
 }
@@ -1069,7 +1069,7 @@ print_indexed (int basereg,
       (*info->fprintf_func) (info->stream, ",%s", buf);
       buf[0] = '\0';
     }
-  sprintf_vma (vmabuf, outer_disp);
+  snprintf(vmabuf, sizeof(vmabuf), "%0" PRIx64, outer_disp);
   (*info->fprintf_func) (info->stream, ")@(%s", vmabuf);
   if (buf[0] != '\0')
     (*info->fprintf_func) (info->stream, ",%s", buf);
-- 
2.41.0



  reply	other threads:[~2024-04-11 21:40 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-11 21:39 [PATCH 0/2] m68k: Remove sprintf() calls due to macOS deprecation Philippe Mathieu-Daudé
2024-04-11 21:39 ` Philippe Mathieu-Daudé [this message]
2024-04-11 21:57   ` [PATCH 1/2] disas/m68k: Replace sprintf() by snprintf() Richard Henderson
2024-04-11 21:39 ` [PATCH 2/2] target/m68k: Remove sprintf() calls Philippe Mathieu-Daudé
2024-04-11 21:58   ` 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=20240411213933.36548-2-philmd@linaro.org \
    --to=philmd@linaro.org \
    --cc=laurent@vivier.eu \
    --cc=qemu-devel@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).