qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V2] qtest: Fix bad printf format specifiers
@ 2020-11-05  6:50 AlexChen
  2020-11-05  7:54 ` Thomas Huth
  2020-11-06  6:36 ` Markus Armbruster
  0 siblings, 2 replies; 3+ messages in thread
From: AlexChen @ 2020-11-05  6:50 UTC (permalink / raw)
  To: Thomas Huth, lvivier, Paolo Bonzini; +Cc: QEMU Trivial, QEMU

We should use printf format specifier PRIu32 instead of "%d" for
argument of type 'uint32_t'.

Reported-by: Euler Robot <euler.robot@huawei.com>
Signed-off-by: Alex Chen <alex.chen@huawei.com>
---
 tests/qtest/arm-cpu-features.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tests/qtest/arm-cpu-features.c b/tests/qtest/arm-cpu-features.c
index d20094d5a7..003ba24fac 100644
--- a/tests/qtest/arm-cpu-features.c
+++ b/tests/qtest/arm-cpu-features.c
@@ -536,7 +536,7 @@ static void test_query_cpu_model_expansion_kvm(const void *data)
         if (kvm_supports_sve) {
             g_assert(vls != 0);
             max_vq = 64 - __builtin_clzll(vls);
-            sprintf(max_name, "sve%d", max_vq * 128);
+            sprintf(max_name, "sve%" PRIu32, max_vq * 128);

             /* Enabling a supported length is of course fine. */
             assert_sve_vls(qts, "host", vls, "{ %s: true }", max_name);
@@ -556,7 +556,7 @@ static void test_query_cpu_model_expansion_kvm(const void *data)
                  * unless all larger, supported vector lengths are also
                  * disabled.
                  */
-                sprintf(name, "sve%d", vq * 128);
+                sprintf(name, "sve%" PRIu32, vq * 128);
                 error = g_strdup_printf("cannot disable %s", name);
                 assert_error(qts, "host", error,
                              "{ %s: true, %s: false }",
@@ -569,7 +569,7 @@ static void test_query_cpu_model_expansion_kvm(const void *data)
              * we need at least one vector length enabled.
              */
             vq = __builtin_ffsll(vls);
-            sprintf(name, "sve%d", vq * 128);
+            sprintf(name, "sve%" PRIu32, vq * 128);
             error = g_strdup_printf("cannot disable %s", name);
             assert_error(qts, "host", error, "{ %s: false }", name);
             g_free(error);
@@ -581,7 +581,7 @@ static void test_query_cpu_model_expansion_kvm(const void *data)
                 }
             }
             if (vq <= SVE_MAX_VQ) {
-                sprintf(name, "sve%d", vq * 128);
+                sprintf(name, "sve%" PRIu32, vq * 128);
                 error = g_strdup_printf("cannot enable %s", name);
                 assert_error(qts, "host", error, "{ %s: true }", name);
                 g_free(error);
-- 
2.19.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH V2] qtest: Fix bad printf format specifiers
  2020-11-05  6:50 [PATCH V2] qtest: Fix bad printf format specifiers AlexChen
@ 2020-11-05  7:54 ` Thomas Huth
  2020-11-06  6:36 ` Markus Armbruster
  1 sibling, 0 replies; 3+ messages in thread
From: Thomas Huth @ 2020-11-05  7:54 UTC (permalink / raw)
  To: AlexChen, lvivier, Paolo Bonzini; +Cc: QEMU Trivial, QEMU

On 05/11/2020 07.50, AlexChen wrote:
> We should use printf format specifier PRIu32 instead of "%d" for
> argument of type 'uint32_t'.
> 
> Reported-by: Euler Robot <euler.robot@huawei.com>
> Signed-off-by: Alex Chen <alex.chen@huawei.com>
> ---
>  tests/qtest/arm-cpu-features.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/tests/qtest/arm-cpu-features.c b/tests/qtest/arm-cpu-features.c
> index d20094d5a7..003ba24fac 100644
> --- a/tests/qtest/arm-cpu-features.c
> +++ b/tests/qtest/arm-cpu-features.c
> @@ -536,7 +536,7 @@ static void test_query_cpu_model_expansion_kvm(const void *data)
>          if (kvm_supports_sve) {
>              g_assert(vls != 0);
>              max_vq = 64 - __builtin_clzll(vls);
> -            sprintf(max_name, "sve%d", max_vq * 128);
> +            sprintf(max_name, "sve%" PRIu32, max_vq * 128);
> 
>              /* Enabling a supported length is of course fine. */
>              assert_sve_vls(qts, "host", vls, "{ %s: true }", max_name);
> @@ -556,7 +556,7 @@ static void test_query_cpu_model_expansion_kvm(const void *data)
>                   * unless all larger, supported vector lengths are also
>                   * disabled.
>                   */
> -                sprintf(name, "sve%d", vq * 128);
> +                sprintf(name, "sve%" PRIu32, vq * 128);
>                  error = g_strdup_printf("cannot disable %s", name);
>                  assert_error(qts, "host", error,
>                               "{ %s: true, %s: false }",
> @@ -569,7 +569,7 @@ static void test_query_cpu_model_expansion_kvm(const void *data)
>               * we need at least one vector length enabled.
>               */
>              vq = __builtin_ffsll(vls);
> -            sprintf(name, "sve%d", vq * 128);
> +            sprintf(name, "sve%" PRIu32, vq * 128);
>              error = g_strdup_printf("cannot disable %s", name);
>              assert_error(qts, "host", error, "{ %s: false }", name);
>              g_free(error);
> @@ -581,7 +581,7 @@ static void test_query_cpu_model_expansion_kvm(const void *data)
>                  }
>              }
>              if (vq <= SVE_MAX_VQ) {
> -                sprintf(name, "sve%d", vq * 128);
> +                sprintf(name, "sve%" PRIu32, vq * 128);
>                  error = g_strdup_printf("cannot enable %s", name);
>                  assert_error(qts, "host", error, "{ %s: true }", name);
>                  g_free(error);

Reviewed-by: Thomas Huth <thuth@redhat.com>



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH V2] qtest: Fix bad printf format specifiers
  2020-11-05  6:50 [PATCH V2] qtest: Fix bad printf format specifiers AlexChen
  2020-11-05  7:54 ` Thomas Huth
@ 2020-11-06  6:36 ` Markus Armbruster
  1 sibling, 0 replies; 3+ messages in thread
From: Markus Armbruster @ 2020-11-06  6:36 UTC (permalink / raw)
  To: AlexChen; +Cc: lvivier, Paolo Bonzini, Thomas Huth, QEMU Trivial, QEMU

AlexChen <alex.chen@huawei.com> writes:

> We should use printf format specifier PRIu32 instead of "%d" for
> argument of type 'uint32_t'.

I prefer v1, which uses %u.

[...]



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-11-06  6:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-05  6:50 [PATCH V2] qtest: Fix bad printf format specifiers AlexChen
2020-11-05  7:54 ` Thomas Huth
2020-11-06  6:36 ` Markus Armbruster

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).