[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 2/5] ui/console-vc: Silence warning about sprintf() on OpenBSD
From: |
Michael Tokarev |
Subject: |
[PULL 2/5] ui/console-vc: Silence warning about sprintf() on OpenBSD |
Date: |
Tue, 22 Oct 2024 09:15:30 +0300 |
From: Thomas Huth <thuth@redhat.com>
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 g_strdup_printf() is certainly better here, so let's switch
to that function instead.
Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
ui/console-vc.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/ui/console-vc.c b/ui/console-vc.c
index 8393d532e7..53fcee88f4 100644
--- a/ui/console-vc.c
+++ b/ui/console-vc.c
@@ -648,7 +648,7 @@ static void vc_putchar(VCChardev *vc, int ch)
QemuTextConsole *s = vc->console;
int i;
int x, y;
- char response[40];
+ g_autofree char *response = NULL;
switch(vc->state) {
case TTY_STATE_NORM:
@@ -821,7 +821,7 @@ static void vc_putchar(VCChardev *vc, int ch)
break;
case 6:
/* report cursor position */
- sprintf(response, "\033[%d;%dR",
+ response = g_strdup_printf("\033[%d;%dR",
(s->y_base + s->y) % s->total_height + 1,
s->x + 1);
vc_respond_str(vc, response);
--
2.39.5
- [PULL 0/5] Trivial patches for 2024-10-22, Michael Tokarev, 2024/10/22
- [PULL 1/5] linux-user: Clean up unused header, Michael Tokarev, 2024/10/22
- [PULL 2/5] ui/console-vc: Silence warning about sprintf() on OpenBSD,
Michael Tokarev <=
- [PULL 3/5] configure: Replace literally printed '\n' with newline, Michael Tokarev, 2024/10/22
- [PULL 4/5] meson.build: Remove ncurses workaround for OpenBSD, Michael Tokarev, 2024/10/22
- [PULL 5/5] replace error_setg(&error_fatal, ...) with error_report(), Michael Tokarev, 2024/10/22
- Re: [PULL 0/5] Trivial patches for 2024-10-22, Peter Maydell, 2024/10/24