[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 1/2] disas/m68k: Replace sprintf() by snprintf()
From: |
Philippe Mathieu-Daudé |
Subject: |
[PATCH 1/2] disas/m68k: Replace sprintf() by snprintf() |
Date: |
Thu, 11 Apr 2024 23:39:32 +0200 |
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