sim: Remove trailing dot when assigning a master's name
authorGiacomo Travaglini <giacomo.travaglini@arm.com>
Wed, 2 May 2018 23:14:42 +0000 (00:14 +0100)
committerGiacomo Travaglini <giacomo.travaglini@arm.com>
Wed, 9 May 2018 17:48:23 +0000 (17:48 +0000)
This patch fixes the master's name allocation in the system. The error
was occurring when a submaster was not specified in getMasterId: a
trailing separation dot was still added to the master's name.

Change-Id: I0e67900f6fdd36a61900453b55219fc7007d1b05
Signed-off-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
Reviewed-on: https://gem5-review.googlesource.com/10301
Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com>
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
Maintainer: Jason Lowe-Power <jason@lowepower.com>

src/sim/system.cc

index 911ee5d9b8d727b124c0fe713e4b0b81a46d7ff3..74bc94ee848b78f49bd10c54b722c60c1779bd9c 100644 (file)
@@ -538,10 +538,13 @@ System::_getMasterId(const SimObject* master, std::string master_name)
 std::string
 System::leafMasterName(const SimObject* master, const std::string& submaster)
 {
-    // Get the full master name by appending the submaster name to
-    // the root SimObject master name
-    auto master_name = master->name() + "." + submaster;
-    return master_name;
+    if (submaster.empty()) {
+        return master->name();
+    } else {
+        // Get the full master name by appending the submaster name to
+        // the root SimObject master name
+        return master->name() + "." + submaster;
+    }
 }
 
 std::string