- vdpa: suspend function return 0 when the vdpa device is stopped - vdpa: don't suspend/resume device when vdpa device not started - vdpa: support vdpa device suspend/resume - vdpa: correct param passed in when unregister save - vdpa: set vring enable only if the vring address has already been set - shadow_dev: introduce shadow dev for virtio-net device - revert "tcg/loongarch64: Fix tcg_out_mov() Aborted" - migration: Set downtime_start even for postcopy - gdb-xml: fix duplicate register in arm-neon.xml - iotests: fix default machine type detection - migration: fix RAMBlock add NULL check - s390x: Fix spelling errors - ppc: spelling fixes - hw/scsi/vhost-scsi: don't double close vhostfd on error - virtio/vhost-vsock: don't double close vhostfd, remove redundant cleanup - hw/scsi/vhost-scsi: don't leak vqs on error - hw/i386/pc: Add missing property descriptions - pcie_aer: Don't trigger a LSI if none are defined - pci: Export the pci_intx() function - hw/qdev: Cosmetic around documentation - tests/unit: fix a -Wformat-truncation warning - tests/avocado: mark ReplayKernelNormal.test_mips64el_malta as flaky - i386/sev: Avoid SEV-ES crash due to missing MSR_EFER_LMA bit - ui/vnc-clipboard: fix inflate_buffer - hw/usb/hcd-xhci.c: spelling: tranfer Signed-off-by: Jiabo Feng <fengjiabo1@huawei.com> (cherry picked from commit 68fee7dc06a6beb5f69d951e22a7f16091f269ff)
54 lines
2.5 KiB
Diff
54 lines
2.5 KiB
Diff
From 133b578fabea9f4cc5936da233c04463bf94b6db Mon Sep 17 00:00:00 2001
|
||
From: boringandboring <wangjinlei_yewu@cmss.chinamobile.com>
|
||
Date: Thu, 7 Dec 2023 09:20:00 +0800
|
||
Subject: [PATCH] tests/unit: fix a -Wformat-truncation warning
|
||
MIME-Version: 1.0
|
||
Content-Type: text/plain; charset=UTF-8
|
||
Content-Transfer-Encoding: 8bit
|
||
|
||
cherry picked from 6a54ac2a9737057dc19aa584d823a3011717423b
|
||
|
||
../tests/test-qobject-input-visitor.c: In function ‘test_visitor_in_list’:
|
||
../tests/test-qobject-input-visitor.c:454:49: warning: ‘%d’ directive output may be truncated writing between 1 and 10 bytes into a region of size 6 [-Wformat-truncation=]
|
||
454 | snprintf(string, sizeof(string), "string%d", i);
|
||
| ^~
|
||
../tests/test-qobject-input-visitor.c:454:42: note: directive argument in the range [0, 2147483606]
|
||
454 | snprintf(string, sizeof(string), "string%d", i);
|
||
| ^~~~~~~~~~
|
||
../tests/test-qobject-input-visitor.c:454:9: note: ‘snprintf’ output between 8 and 17 bytes into a destination of size 12
|
||
454 | snprintf(string, sizeof(string), "string%d", i);
|
||
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||
|
||
Rather than trying to be clever, since this is called 3 times during
|
||
tests, let's simply use g_strdup_printf().
|
||
|
||
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
|
||
Reviewed-by: Markus Armbruster <armbru@redhat.com>
|
||
Message-id: 20220810121513.1356081-1-marcandre.lureau@redhat.com
|
||
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
|
||
[PMM: fixed commit message typos]
|
||
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
|
||
Signed-off-by: boringandboring <wangjinlei_yewu@cmss.chinamobile.com>
|
||
---
|
||
tests/unit/test-qobject-input-visitor.c | 3 +--
|
||
1 file changed, 1 insertion(+), 2 deletions(-)
|
||
|
||
diff --git a/tests/unit/test-qobject-input-visitor.c b/tests/unit/test-qobject-input-visitor.c
|
||
index 6f59a7f432..0f28d46a4a 100644
|
||
--- a/tests/unit/test-qobject-input-visitor.c
|
||
+++ b/tests/unit/test-qobject-input-visitor.c
|
||
@@ -448,9 +448,8 @@ static void test_visitor_in_list(TestInputVisitorData *data,
|
||
g_assert(head != NULL);
|
||
|
||
for (i = 0, item = head; item; item = item->next, i++) {
|
||
- char string[12];
|
||
+ g_autofree char *string = g_strdup_printf("string%d", i);
|
||
|
||
- snprintf(string, sizeof(string), "string%d", i);
|
||
g_assert_cmpstr(item->value->string, ==, string);
|
||
g_assert_cmpint(item->value->integer, ==, 42 + i);
|
||
}
|
||
--
|
||
2.27.0
|
||
|