[PATCH] tests/qtest/migration-test: Do not try to print NULL pointer string

Thomas Huth posted 1 patch 1 year, 7 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20221017105506.69149-1-thuth@redhat.com
Maintainers: Juan Quintela <quintela@redhat.com>, "Dr. David Alan Gilbert" <dgilbert@redhat.com>, Thomas Huth <thuth@redhat.com>, Laurent Vivier <lvivier@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>
tests/qtest/migration-test.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
[PATCH] tests/qtest/migration-test: Do not try to print NULL pointer string
Posted by Thomas Huth 1 year, 7 months ago
If tmpfs is NULL, we should not try to print it as a string.

Reported-by: shengjiangwuqq on github.com
Fixes: e5553c1b8d ("tests/qtest: migration-test: Avoid using hardcoded /tmp")
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 tests/qtest/migration-test.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c
index ef4427ff4d..de70611f50 100644
--- a/tests/qtest/migration-test.c
+++ b/tests/qtest/migration-test.c
@@ -2481,8 +2481,7 @@ 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("g_dir_make_tmp failed: %s", err->message);
     }
     g_assert(tmpfs);
 
-- 
2.31.1
Re: [PATCH] tests/qtest/migration-test: Do not try to print NULL pointer string
Posted by Markus Armbruster 1 year, 7 months ago
Thomas Huth <thuth@redhat.com> writes:

> If tmpfs is NULL, we should not try to print it as a string.
>
> Reported-by: shengjiangwuqq on github.com
> Fixes: e5553c1b8d ("tests/qtest: migration-test: Avoid using hardcoded /tmp")
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
>  tests/qtest/migration-test.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c
> index ef4427ff4d..de70611f50 100644
> --- a/tests/qtest/migration-test.c
> +++ b/tests/qtest/migration-test.c
> @@ -2481,8 +2481,7 @@ 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("g_dir_make_tmp failed: %s", err->message);
>      }
>      g_assert(tmpfs);

Reviewed-by: Markus Armbruster <armbru@redhat.com>