diff mbox series

[v2,1/2] tests/qtest: migration-test: Fix [-Werror=format-overflow=] build warning

Message ID 20221017132023.2228641-1-bmeng.cn@gmail.com
State New
Headers show
Series [v2,1/2] tests/qtest: migration-test: Fix [-Werror=format-overflow=] build warning | expand

Commit Message

Bin Meng Oct. 17, 2022, 1:20 p.m. UTC
From: Bin Meng <bin.meng@windriver.com>

When tmpfs is NULL, a build warning is seen with GCC 9.3.0.
It's strange that GCC 11.2.0 on Ubuntu 22.04 does not catch this,
neither did the QEMU CI.

While we are here, improve the error message as well.

Reported-by: Shengjiang Wu <shengjiang.wu@windriver.com>
Fixes: e5553c1b8d28 ("tests/qtest: migration-test: Avoid using hardcoded /tmp")
Signed-off-by: Bin Meng <bin.meng@windriver.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
---

Changes in v2:
- improve the error message

 tests/qtest/migration-test.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Laurent Vivier Oct. 22, 2022, 9:17 p.m. UTC | #1
Le 17/10/2022 à 15:20, Bin Meng a écrit :
> From: Bin Meng <bin.meng@windriver.com>
> 
> When tmpfs is NULL, a build warning is seen with GCC 9.3.0.
> It's strange that GCC 11.2.0 on Ubuntu 22.04 does not catch this,
> neither did the QEMU CI.
> 
> While we are here, improve the error message as well.
> 
> Reported-by: Shengjiang Wu <shengjiang.wu@windriver.com>
> Fixes: e5553c1b8d28 ("tests/qtest: migration-test: Avoid using hardcoded /tmp")
> Signed-off-by: Bin Meng <bin.meng@windriver.com>
> Reviewed-by: Markus Armbruster <armbru@redhat.com>
> ---
> 
> Changes in v2:
> - improve the error message
> 
>   tests/qtest/migration-test.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c
> index ef4427ff4d..aa1ba179fa 100644
> --- a/tests/qtest/migration-test.c
> +++ b/tests/qtest/migration-test.c
> @@ -2481,8 +2481,8 @@ int main(int argc, char **argv)
>   
>       tmpfs = g_dir_make_tmp("migration-test-XXXXXX", &err);
>       if (!tmpfs) {
> -        g_test_message("g_dir_make_tmp on path (%s): %s", tmpfs,
> -                       err->message);
> +        g_test_message("Can't create temporary directory in %s: %s",
> +                       g_get_tmp_dir(), err->message);
>       }
>       g_assert(tmpfs);
>   
Applied to my trivial-patches branch.

Thanks,
Laurent
diff mbox series

Patch

diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c
index ef4427ff4d..aa1ba179fa 100644
--- a/tests/qtest/migration-test.c
+++ b/tests/qtest/migration-test.c
@@ -2481,8 +2481,8 @@  int main(int argc, char **argv)
 
     tmpfs = g_dir_make_tmp("migration-test-XXXXXX", &err);
     if (!tmpfs) {
-        g_test_message("g_dir_make_tmp on path (%s): %s", tmpfs,
-                       err->message);
+        g_test_message("Can't create temporary directory in %s: %s",
+                       g_get_tmp_dir(), err->message);
     }
     g_assert(tmpfs);