qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Huth <thuth@redhat.com>
To: "Marc-André Lureau" <marcandre.lureau@redhat.com>, qemu-devel@nongnu.org
Cc: Brad Smith <brad@comstyle.com>, qemu-trivial@nongnu.org
Subject: [PATCH] ui/console-vc: Silence warning about sprintf() on OpenBSD
Date: Mon, 14 Oct 2024 17:10:23 +0200	[thread overview]
Message-ID: <20241014151023.85698-1-thuth@redhat.com> (raw)

The linker on OpenBSD complains:

 ld: warning: console-vc.c:824 (../src/ui/console-vc.c:824)([...]):
 warning: sprintf() is often misused, please use snprintf()

Using snprintf() is certainly better here, so let's switch to that
function instead.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 ui/console-vc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/ui/console-vc.c b/ui/console-vc.c
index 8393d532e7..336a1520eb 100644
--- a/ui/console-vc.c
+++ b/ui/console-vc.c
@@ -821,9 +821,9 @@ static void vc_putchar(VCChardev *vc, int ch)
                     break;
                 case 6:
                     /* report cursor position */
-                    sprintf(response, "\033[%d;%dR",
-                           (s->y_base + s->y) % s->total_height + 1,
-                            s->x + 1);
+                    snprintf(response, sizeof(response), "\033[%d;%dR",
+                             (s->y_base + s->y) % s->total_height + 1,
+                             s->x + 1);
                     vc_respond_str(vc, response);
                     break;
                 }
-- 
2.46.1



             reply	other threads:[~2024-10-14 15:11 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-14 15:10 Thomas Huth [this message]
2024-10-14 15:15 ` [PATCH] ui/console-vc: Silence warning about sprintf() on OpenBSD Daniel P. Berrangé
2024-10-14 19:50   ` Michael Tokarev
2024-10-15  8:08     ` Alex Bennée
2024-10-15  8:14     ` Daniel P. Berrangé
2024-10-15 11:28       ` Thomas Huth
2024-10-15  6:34 ` Marc-André Lureau

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=20241014151023.85698-1-thuth@redhat.com \
    --to=thuth@redhat.com \
    --cc=brad@comstyle.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@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).