Patchwork qtest: fix memread and memwrite on 32 bit hosts

login
register
mail settings
Submitter Blue Swirl
Date April 23, 2012, 6:55 p.m.
Message ID <CAAu8pHtQQkH7TNu7hTE4QkE23rBqAWcfu+4=fXZFnoeeY+3Juw@mail.gmail.com>
Download mbox | patch
Permalink /patch/154525/
State New
Headers show

Comments

Blue Swirl - April 23, 2012, 6:55 p.m.
Use PRIx64 to print 64 bit values to avoid truncation
on 32 bit hosts.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
---
 tests/libqtest.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

     for (i = 0; i < size; i++) {
@@ -378,7 +378,7 @@ void qtest_memwrite(QTestState *s, uint64_t addr,
const void *data, size_t size)
     const uint8_t *ptr = data;
     size_t i;

-    qtest_sendf(s, "write 0x%x 0x%x 0x", addr, size);
+    qtest_sendf(s, "write 0x%" PRIx64 " 0x%x 0x", addr, size);
     for (i = 0; i < size; i++) {
         qtest_sendf(s, "%02x", ptr[i]);
     }
Anthony Liguori - April 23, 2012, 7:13 p.m.
On 04/23/2012 01:55 PM, Blue Swirl wrote:
> Use PRIx64 to print 64 bit values to avoid truncation
> on 32 bit hosts.
>
> Signed-off-by: Blue Swirl<blauwirbel@gmail.com>

Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>

Regards,

Anthony Liguori

> ---
>   tests/libqtest.c |    4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tests/libqtest.c b/tests/libqtest.c
> index d47969e..1ce6fa1 100644
> --- a/tests/libqtest.c
> +++ b/tests/libqtest.c
> @@ -356,7 +356,7 @@ void qtest_memread(QTestState *s, uint64_t addr,
> void *data, size_t size)
>       gchar **args;
>       size_t i;
>
> -    qtest_sendf(s, "read 0x%x 0x%x\n", addr, size);
> +    qtest_sendf(s, "read 0x%" PRIx64 " 0x%x\n", addr, size);
>       args = qtest_rsp(s, 2);
>
>       for (i = 0; i<  size; i++) {
> @@ -378,7 +378,7 @@ void qtest_memwrite(QTestState *s, uint64_t addr,
> const void *data, size_t size)
>       const uint8_t *ptr = data;
>       size_t i;
>
> -    qtest_sendf(s, "write 0x%x 0x%x 0x", addr, size);
> +    qtest_sendf(s, "write 0x%" PRIx64 " 0x%x 0x", addr, size);
>       for (i = 0; i<  size; i++) {
>           qtest_sendf(s, "%02x", ptr[i]);
>       }
Blue Swirl - April 23, 2012, 7:31 p.m.
On Mon, Apr 23, 2012 at 19:13, Anthony Liguori <aliguori@us.ibm.com> wrote:
> On 04/23/2012 01:55 PM, Blue Swirl wrote:
>>
>> Use PRIx64 to print 64 bit values to avoid truncation
>> on 32 bit hosts.
>>
>> Signed-off-by: Blue Swirl<blauwirbel@gmail.com>
>
>
> Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>

Thanks for the review, applied.

>
> Regards,
>
> Anthony Liguori
>
>
>> ---
>>  tests/libqtest.c |    4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/tests/libqtest.c b/tests/libqtest.c
>> index d47969e..1ce6fa1 100644
>> --- a/tests/libqtest.c
>> +++ b/tests/libqtest.c
>> @@ -356,7 +356,7 @@ void qtest_memread(QTestState *s, uint64_t addr,
>> void *data, size_t size)
>>      gchar **args;
>>      size_t i;
>>
>> -    qtest_sendf(s, "read 0x%x 0x%x\n", addr, size);
>> +    qtest_sendf(s, "read 0x%" PRIx64 " 0x%x\n", addr, size);
>>      args = qtest_rsp(s, 2);
>>
>>      for (i = 0; i<  size; i++) {
>> @@ -378,7 +378,7 @@ void qtest_memwrite(QTestState *s, uint64_t addr,
>> const void *data, size_t size)
>>      const uint8_t *ptr = data;
>>      size_t i;
>>
>> -    qtest_sendf(s, "write 0x%x 0x%x 0x", addr, size);
>> +    qtest_sendf(s, "write 0x%" PRIx64 " 0x%x 0x", addr, size);
>>      for (i = 0; i<  size; i++) {
>>          qtest_sendf(s, "%02x", ptr[i]);
>>      }
>
>
Stefan Weil - April 23, 2012, 7:34 p.m.
Am 23.04.2012 21:31, schrieb Blue Swirl:
> On Mon, Apr 23, 2012 at 19:13, Anthony Liguori<aliguori@us.ibm.com>  wrote:
>    
>> On 04/23/2012 01:55 PM, Blue Swirl wrote:
>>      
>>> Use PRIx64 to print 64 bit values to avoid truncation
>>> on 32 bit hosts.
>>>
>>> Signed-off-by: Blue Swirl<blauwirbel@gmail.com>
>>>        
>>
>> Reviewed-by: Anthony Liguori<aliguori@us.ibm.com>
>>      
> Thanks for the review, applied.
>
>    


You are really fast :-)

I was just also writing a (different) review, but will now send a patch :-)

Cheers,
Stefan W.

Patch

diff --git a/tests/libqtest.c b/tests/libqtest.c
index d47969e..1ce6fa1 100644
--- a/tests/libqtest.c
+++ b/tests/libqtest.c
@@ -356,7 +356,7 @@  void qtest_memread(QTestState *s, uint64_t addr,
void *data, size_t size)
     gchar **args;
     size_t i;

-    qtest_sendf(s, "read 0x%x 0x%x\n", addr, size);
+    qtest_sendf(s, "read 0x%" PRIx64 " 0x%x\n", addr, size);
     args = qtest_rsp(s, 2);