From: Giacomo Travaglini Date: Thu, 27 Feb 2020 15:13:51 +0000 (+0000) Subject: learning-gem5: Use zero initialization in hello_goodbye test X-Git-Tag: v20.0.0.0~450 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=5c825a5d724653ad3389cf565893fd0ee7dad194;p=gem5.git learning-gem5: Use zero initialization in hello_goodbye test 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 Reviewed-by: Nikos Nikoleris Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/25987 Reviewed-by: Bobby R. Bruce Reviewed-by: Jason Lowe-Power Maintainer: Jason Lowe-Power Tested-by: kokoro --- diff --git a/src/learning_gem5/part2/goodbye_object.cc b/src/learning_gem5/part2/goodbye_object.cc index d27de741b..1314bb2e9 100644 --- a/src/learning_gem5/part2/goodbye_object.cc +++ b/src/learning_gem5/part2/goodbye_object.cc @@ -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"); }