learning-gem5: Use zero initialization in hello_goodbye test
authorGiacomo Travaglini <giacomo.travaglini@arm.com>
Thu, 27 Feb 2020 15:13:51 +0000 (15:13 +0000)
committerGiacomo Travaglini <giacomo.travaglini@arm.com>
Fri, 28 Feb 2020 09:32:30 +0000 (09:32 +0000)
This is likely fixing:

JIRA: https://gem5.atlassian.net/browse/GEM5-328

the exitCause method was randomically printing an invalid string coming
from a non 0 terminated char buffer, whose pointer is provided via the
exitSimLoop.
By doing zero-initialization we make sure last character is '\0'.

Change-Id: I514a9bd240a0d5489ce9652ad14289f834752abe
Signed-off-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/25987
Reviewed-by: Bobby R. Bruce <bbruce@ucdavis.edu>
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
Maintainer: Jason Lowe-Power <jason@lowepower.com>
Tested-by: kokoro <noreply+kokoro@google.com>
src/learning_gem5/part2/goodbye_object.cc

index d27de741b8d7f8d0eb9b528d01c0e10c2bfe0a97..1314bb2e9922dfb3927db1432136e50460216aa7 100644 (file)
@@ -36,7 +36,7 @@ GoodbyeObject::GoodbyeObject(GoodbyeObjectParams *params) :
     bandwidth(params->write_bandwidth), bufferSize(params->buffer_size),
     buffer(nullptr), bufferUsed(0)
 {
-    buffer = new char[bufferSize];
+    buffer = new char[bufferSize]();
     DPRINTF(HelloExample, "Created the goodbye object\n");
 }