From: Steve Reinhardt Date: Mon, 6 Aug 2012 23:57:11 +0000 (-0700) Subject: SETranslatingPortProxy: fix bug in tryReadString() X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f4b424cd539eed26de18e81fd9d433cd6ae6295b;p=gem5.git SETranslatingPortProxy: fix bug in tryReadString() Off-by-one loop termination meant that we were stuffing the terminating '\0' into the std::string value, which makes for difficult-to-debug string comparison failures. --- diff --git a/src/mem/se_translating_port_proxy.cc b/src/mem/se_translating_port_proxy.cc index 72466655c..7857217f6 100644 --- a/src/mem/se_translating_port_proxy.cc +++ b/src/mem/se_translating_port_proxy.cc @@ -190,15 +190,18 @@ SETranslatingPortProxy::tryReadString(std::string &str, Addr addr) const Addr vaddr = addr; - do { + while (true) { Addr paddr; if (!pTable->translate(vaddr++, paddr)) return false; PortProxy::readBlob(paddr, &c, 1); + if (c == '\0') + break; + str += c; - } while (c); + } return true; }