Skip to contentSkip to conversation

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

PATCH Superseded Bin Meng 3 participants 8 messages Oct 17, 2022

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Bin Meng

author
#0 lore raw

PATCH 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.

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

---

 tests/qtest/migration-test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/qtest/migration-test.c +1 -1
index ef4427ff4d..83a8998e40 100644
@@ -2481,7 +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,
+        g_test_message("g_dir_make_tmp on path (%s): %s", g_get_tmp_dir(),
                        err->message);
     }
     g_assert(tmpfs);
Signature · 1 line
2.34.1
author
#1 lore raw

PATCH 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.

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

---

 tests/qtest/vhost-user-test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/qtest/vhost-user-test.c +1 -1
index e8d2da7228..819b87df3c 100644
@@ -571,7 +571,7 @@ 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,
+        g_test_message("g_dir_make_tmp on path (%s): %s", g_get_tmp_dir(),
                        err->message);
         g_error_free(err);
     }
Signature · 1 line
2.34.1
Reviewed-by on v1 2/2
#2 lore raw

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

Quoted 19 lines · Bin Meng

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.

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

---

 tests/qtest/vhost-user-test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/qtest/vhost-user-test.c +0 -0
index e8d2da7228..819b87df3c 100644

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

Quoted 8 lines
tests/qtest/vhost-user-test.c +1 -1
@@ -571,7 +571,7 @@ 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,
+        g_test_message("g_dir_make_tmp on path (%s): %s", g_get_tmp_dir(),
                        err->message);
         g_error_free(err);
     }

Suggest to improve the error message while there: "can't create temporary file in %s: %s"

author
#3 lore raw

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

Quoted 23 lines · Markus Armbruster
Quoted 20 lines · Bin Meng

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.

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

---

 tests/qtest/vhost-user-test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/qtest/vhost-user-test.c +0 -0
index e8d2da7228..819b87df3c 100644
@@ -571,7 +571,7 @@ static TestServer *test_server_new(const gchar *name,
 
Quoted 10 lines

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

Quoted 7 lines
tests/qtest/vhost-user-test.c +1 -1
     tmpfs = g_dir_make_tmp("vhost-test-XXXXXX", &err);
     if (!tmpfs) {
-        g_test_message("g_dir_make_tmp on path (%s): %s", tmpfs,
+        g_test_message("g_dir_make_tmp on path (%s): %s", g_get_tmp_dir(),
                        err->message);
         g_error_free(err);
     }

Suggest to improve the error message while there: "can't create temporary file in %s: %s"

Thanks for the review. I've sent v2 with the suggested improvement on the error message.

Quoted 3 lines

Regards,
Bin

Reviewed-by on v1 1/2
#4 lore raw
In reply to Bin Meng
Quoted 19 lines · Bin Meng

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.

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

---

 tests/qtest/migration-test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/qtest/migration-test.c +0 -0
index ef4427ff4d..83a8998e40 100644

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

Quoted 8 lines
tests/qtest/migration-test.c +1 -1
@@ -2481,7 +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,
+        g_test_message("g_dir_make_tmp on path (%s): %s", g_get_tmp_dir(),
                        err->message);
     }
     g_assert(tmpfs);

Thomas posted the same fix as "[PATCH] tests/qtest/migration-test: Do not try to print NULL pointer string". You guys figure out which one you like better :)

#5 lore raw
Quoted 22 lines · Markus Armbruster
Quoted 20 lines · Bin Meng

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.

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

---

 tests/qtest/migration-test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/qtest/migration-test.c +0 -0
index ef4427ff4d..83a8998e40 100644
@@ -2481,7 +2481,7 @@ int main(int argc, char **argv)
 
Quoted 11 lines

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

Quoted 7 lines
tests/qtest/migration-test.c +1 -1
     tmpfs = g_dir_make_tmp("migration-test-XXXXXX", &err);
     if (!tmpfs) {
-        g_test_message("g_dir_make_tmp on path (%s): %s", tmpfs,
+        g_test_message("g_dir_make_tmp on path (%s): %s", g_get_tmp_dir(),
                        err->message);
     }
     g_assert(tmpfs);

Thomas posted the same fix as "[PATCH] tests/qtest/migration-test: Do not try to print NULL pointer string". You guys figure out which one you like better :)

Correction: not the same.

Quoted 1 line
author
#6 lore raw
In reply to Markus Armbruster
Quoted 23 lines · Markus Armbruster
Quoted 20 lines · Bin Meng

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.

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

---

 tests/qtest/migration-test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/qtest/migration-test.c +0 -0
index ef4427ff4d..83a8998e40 100644
@@ -2481,7 +2481,7 @@ int main(int argc, char **argv)
 
Quoted 12 lines

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

Quoted 7 lines
tests/qtest/migration-test.c +1 -1
     tmpfs = g_dir_make_tmp("migration-test-XXXXXX", &err);
     if (!tmpfs) {
-        g_test_message("g_dir_make_tmp on path (%s): %s", tmpfs,
+        g_test_message("g_dir_make_tmp on path (%s): %s", g_get_tmp_dir(),
                        err->message);
     }
     g_assert(tmpfs);

Thomas posted the same fix as "[PATCH] tests/qtest/migration-test: Do not try to print NULL pointer string". You guys figure out which one you like better :)

Oops, almost the same time :)

Will let Thomas decide.

Quoted 2 lines

Regards,
Bin

#7 lore raw
Quoted 37 lines · Bin Meng
Quoted 23 lines · Markus Armbruster
Quoted 20 lines · Bin Meng

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.

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

---

  tests/qtest/migration-test.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
tests/qtest/migration-test.c +0 -0
index ef4427ff4d..83a8998e40 100644
@@ -2481,7 +2481,7 @@ int main(int argc, char **argv)
 
Quoted 12 lines

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

Quoted 7 lines
tests/qtest/migration-test.c +1 -1
      tmpfs = g_dir_make_tmp("migration-test-XXXXXX", &err);
      if (!tmpfs) {
-        g_test_message("g_dir_make_tmp on path (%s): %s", tmpfs,
+        g_test_message("g_dir_make_tmp on path (%s): %s", g_get_tmp_dir(),
                         err->message);
      }
      g_assert(tmpfs);

Thomas posted the same fix as "[PATCH] tests/qtest/migration-test: Do not try to print NULL pointer string". You guys figure out which one you like better :)

Quoted 3 lines

Oops, almost the same time :)

Will let Thomas decide.

The improvement of the error message in your v2 makes a lot of sense - I'll queue that version.

Thomas