Skip to contentSkip to conversation

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

PATCH Applied Bin Meng 2 participants 4 messages Oct 17, 2022 – Oct 22, 2022

lore
Share & tools
lore

Bin Meng

author
#0 lore raw

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

From: Bin Meng <[email protected]>

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.

Fixes e5553c1b8d28 ("tests/qtest: migration-test: Avoid using hardcoded /tmp")

---

Changes in v2:
- improve the error message

 tests/qtest/migration-test.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tests/qtest/migration-test.c +2 -2
index ef4427ff4d..aa1ba179fa 100644
@@ -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);
 
Signature · 1 line
2.34.1
author
#1 lore raw

PATCH v2 2/2 tests/qtest: vhost-user-test: Fix [-Werror=format-overflow=] build warning

From: Bin Meng <[email protected]>

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.

Fixes e6efe236c1d1 ("tests/qtest: vhost-user-test: Avoid using hardcoded /tmp")

---

Changes in v2:
- improve the error message

 tests/qtest/vhost-user-test.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tests/qtest/vhost-user-test.c +2 -2
index e8d2da7228..bf9f7c4248 100644
@@ -571,8 +571,8 @@ static TestServer *test_server_new(const gchar *name,
 
     tmpfs = g_dir_make_tmp("vhost-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_error_free(err);
     }
     g_assert(tmpfs);
Signature · 1 line
2.34.1
#2 lore raw

Re: [PATCH v2 2/2] tests/qtest: vhost-user-test: Fix [-Werror=format-overflow=] build warning

Le 17/10/2022 à 15:20, Bin Meng a écrit :

Quoted 25 lines

From: Bin Meng <[email protected]>

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.

Fixes e6efe236c1d1 ("tests/qtest: vhost-user-test: Avoid using hardcoded /tmp")

---

Changes in v2:
- improve the error message

  tests/qtest/vhost-user-test.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
tests/qtest/vhost-user-test.c +0 -0
index e8d2da7228..bf9f7c4248 100644

tests/qtest/vhost-user-test.c static TestServer *test_server_new(const gchar *name, · line 578

Quoted 10 lines
tests/qtest/vhost-user-test.c +2 -2
@@ -571,8 +571,8 @@ static TestServer *test_server_new(const gchar *name,
 
      tmpfs = g_dir_make_tmp("vhost-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_error_free(err);
      }
      g_assert(tmpfs);

Applied to my trivial-patches branch.

Thanks,
Laurent

#3 lore raw
In reply to Bin Meng

Le 17/10/2022 à 15:20, Bin Meng a écrit :

Quoted 25 lines

From: Bin Meng <[email protected]>

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.

Fixes e5553c1b8d28 ("tests/qtest: migration-test: Avoid using hardcoded /tmp")

---

Changes in v2:
- improve the error message

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

tests/qtest/migration-test.c int main(int argc, char **argv) · line 2488

Quoted 10 lines
tests/qtest/migration-test.c +2 -2
@@ -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