From fc7ada3e7c1e15c9aec1d4eb708fe7bac5a1ba5e Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Wed, 25 Mar 2020 16:22:37 -0700 Subject: [PATCH] sim: Simplify collecting the key value in initParam. If the first register is all zeroes, it doesn't really matter what the other register is. If the first register has the entire string, we still don't care what the other register has in it. There's no reason to complicate the code with these extra checks. Change-Id: I22ad521b9ace915ccb75f15934fc6b3d650d5293 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/27228 Maintainer: Bobby R. Bruce Tested-by: kokoro Reviewed-by: Ciro Santilli --- src/sim/pseudo_inst.cc | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/sim/pseudo_inst.cc b/src/sim/pseudo_inst.cc index a450bd885..534f70635 100644 --- a/src/sim/pseudo_inst.cc +++ b/src/sim/pseudo_inst.cc @@ -259,18 +259,9 @@ initParam(ThreadContext *tc, uint64_t key_str1, uint64_t key_str2) const int len = 2 * sizeof(uint64_t) + 1; char key_str[len]; memset(key_str, '\0', len); - if (key_str1 == 0) { - assert(key_str2 == 0); - } else { - strncpy(key_str, (char *)&key_str1, sizeof(uint64_t)); - } - if (strlen(key_str) == sizeof(uint64_t)) { - strncpy(key_str + sizeof(uint64_t), (char *)&key_str2, - sizeof(uint64_t)); - } else { - assert(key_str2 == 0); - } + memcpy(key_str, (char *)&key_str1, sizeof(key_str1)); + memcpy(key_str + sizeof(uint64_t), (char *)&key_str2, sizeof(key_str2)); // Compare the key parameter with the known values to select the return // value -- 2.30.2