Skip to contentSkip to conversation

ide: remove undefined behavior in ide-test

PATCH Applied John Snow 3 participants 4 messages Feb 8, 2017 – Feb 15, 2017

lore
Share & tools
lore

John Snow

author
#0 lore raw

PATCH 1/1 ide: remove undefined behavior in ide-test

trivial: initialize the dirty buffer with a random-ish byte. Stops valgrind from whining about uninitialized buffers.

---
 tests/ide-test.c | 1 +
 1 file changed, 1 insertion(+)
tests/ide-test.c +1 -0
index 2fa97bc..139ebc0 100644
@@ -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);
 
Signature · 1 line
2.9.3
Reviewed-by on v1 1/1
#1 lore raw
Quoted 13 lines · John Snow

trivial: initialize the dirty buffer with a random-ish byte. Stops valgrind from whining about uninitialized buffers.

---
 tests/ide-test.c | 1 +
 1 file changed, 1 insertion(+)
tests/ide-test.c +0 -0
index 2fa97bc..139ebc0 100644

tests/ide-test.c static void make_dirty(uint8_t device) · line 553

Quoted 4 lines
tests/ide-test.c +1 -0
@@ -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);

tests/ide-test.c static void make_dirty(uint8_t device) · line 555

Quoted 2 lines
tests/ide-test.c +0 -0
     g_assert(guest_buf);
     g_assert(buf);

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

author
#2 lore raw
Quoted 15 lines · Stefan Hajnoczi
Quoted 14 lines · John Snow

trivial: initialize the dirty buffer with a random-ish byte. Stops valgrind from whining about uninitialized buffers.

---
 tests/ide-test.c | 1 +
 1 file changed, 1 insertion(+)
tests/ide-test.c +0 -0
index 2fa97bc..139ebc0 100644
@@ -550,6 +550,7 @@ static void make_dirty(uint8_t device)
 
Quoted 6 lines

tests/ide-test.c static void make_dirty(uint8_t device) · line 553

Quoted 3 lines
tests/ide-test.c +1 -0
     guest_buf = guest_alloc(guest_malloc, len);
     buf = g_malloc(len);
+    memset(buf, rand() % 255 + 1, len);

Thanks.

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

Quoted 7 lines

tests/ide-test.c static void make_dirty(uint8_t device) · line 555

Quoted 2 lines
tests/ide-test.c +0 -0
     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 ...

#3 lore raw
In reply to John Snow
Quoted 2 lines · John Snow

trivial: initialize the dirty buffer with a random-ish byte. Stops valgrind from whining about uninitialized buffers.

Applied to -trivial, thanks!

/mjt