[Qemu-devel] [PATCH] ide: remove undefined behavior in ide-test

John Snow posted 1 patch 7 years, 2 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20170208170533.28822-1-jsnow@redhat.com
Test checkpatch passed
Test docker passed
Test s390x passed
tests/ide-test.c | 1 +
1 file changed, 1 insertion(+)
[Qemu-devel] [PATCH] ide: remove undefined behavior in ide-test
Posted by John Snow 7 years, 2 months ago
trivial: initialize the dirty buffer with a random-ish byte.
Stops valgrind from whining about uninitialized buffers.

Signed-off-by: John Snow <jsnow@redhat.com>
---
 tests/ide-test.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tests/ide-test.c b/tests/ide-test.c
index 2fa97bc..139ebc0 100644
--- a/tests/ide-test.c
+++ b/tests/ide-test.c
@@ -550,6 +550,7 @@ static void make_dirty(uint8_t device)
 
     guest_buf = guest_alloc(guest_malloc, len);
     buf = g_malloc(len);
+    memset(buf, rand() % 255 + 1, len);
     g_assert(guest_buf);
     g_assert(buf);
 
-- 
2.9.3


Re: [Qemu-devel] [PATCH] ide: remove undefined behavior in ide-test
Posted by Stefan Hajnoczi 7 years, 2 months ago
On Wed, Feb 08, 2017 at 12:05:33PM -0500, John Snow wrote:
> trivial: initialize the dirty buffer with a random-ish byte.
> Stops valgrind from whining about uninitialized buffers.
> 
> Signed-off-by: John Snow <jsnow@redhat.com>
> ---
>  tests/ide-test.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/tests/ide-test.c b/tests/ide-test.c
> index 2fa97bc..139ebc0 100644
> --- a/tests/ide-test.c
> +++ b/tests/ide-test.c
> @@ -550,6 +550,7 @@ static void make_dirty(uint8_t device)
>  
>      guest_buf = guest_alloc(guest_malloc, len);
>      buf = g_malloc(len);
> +    memset(buf, rand() % 255 + 1, len);

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>

>      g_assert(guest_buf);
>      g_assert(buf);

Pre-existing issue:
g_assert(buf) is unnecessary since g_malloc() is guaranteed to return
non-NULL.
Re: [Qemu-devel] [PATCH] ide: remove undefined behavior in ide-test
Posted by John Snow 7 years, 2 months ago

On 02/13/2017 10:00 AM, Stefan Hajnoczi wrote:
> On Wed, Feb 08, 2017 at 12:05:33PM -0500, John Snow wrote:
>> trivial: initialize the dirty buffer with a random-ish byte.
>> Stops valgrind from whining about uninitialized buffers.
>>
>> Signed-off-by: John Snow <jsnow@redhat.com>
>> ---
>>  tests/ide-test.c | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/tests/ide-test.c b/tests/ide-test.c
>> index 2fa97bc..139ebc0 100644
>> --- a/tests/ide-test.c
>> +++ b/tests/ide-test.c
>> @@ -550,6 +550,7 @@ static void make_dirty(uint8_t device)
>>  
>>      guest_buf = guest_alloc(guest_malloc, len);
>>      buf = g_malloc(len);
>> +    memset(buf, rand() % 255 + 1, len);
> 
> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
> 

Thanks.

This can go in through the next TRIVIAL pull, as my queue is otherwise
empty right now.

>>      g_assert(guest_buf);
>>      g_assert(buf);
> 
> Pre-existing issue:
> g_assert(buf) is unnecessary since g_malloc() is guaranteed to return
> non-NULL.
> 

Yeah, I did see that ...

Re: [Qemu-devel] [PATCH] ide: remove undefined behavior in ide-test
Posted by Michael Tokarev 7 years, 2 months ago
08.02.2017 20:05, John Snow wrote:
> trivial: initialize the dirty buffer with a random-ish byte.
> Stops valgrind from whining about uninitialized buffers.

Applied to -trivial, thanks!

/mjt