qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 1/2] disas/m68k: Replace sprintf() by snprintf()


From: Richard Henderson
Subject: Re: [PATCH 1/2] disas/m68k: Replace sprintf() by snprintf()
Date: Thu, 11 Apr 2024 14:57:58 -0700
User-agent: Mozilla Thunderbird

On 4/11/24 14:39, Philippe Mathieu-Daudé wrote:
@@ -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);

In both cases, there's no need for the sprintf at all.
Fold everything into the adjacent fprintf.


r~



reply via email to

[Prev in Thread] Current Thread [Next in Thread]