From: Robert Kovacsics Date: Thu, 19 Jul 2018 16:50:06 +0000 (+0100) Subject: mem: Removed "using namespace std;" from src/mem/packet.cc X-Git-Tag: v19.0.0.0~1997 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4158138d1f0ef14b7be2f55382836821b7ac09d5;p=gem5.git mem: Removed "using namespace std;" from src/mem/packet.cc To avoid unintentional variable capture, all std calls must be prefixed. These are the identifiers which are in the std namespace (according to https://en.cppreference.com/w/cpp/symbol_index), but that will remain unprefixed with this change: int8_t int16_t int32_t int64_t uint8_t uint16_t uint32_t uint64_t The (u)int types are included from the packet header file, which includes , where they occur in the global namespace. They are in the std namespace in /. There is an occurrence of "set" in this file, which is "Packet::set" and not "std::set", so it is not prefixed with the std namespace Change-Id: I7f6c0b61b09658e224fe31a9f73150b81861d6f8 Reviewed-on: https://gem5-review.googlesource.com/11809 Reviewed-by: Daniel Carvalho Reviewed-by: Jason Lowe-Power Reviewed-by: Nikos Nikoleris Maintainer: Jason Lowe-Power --- diff --git a/src/mem/packet.cc b/src/mem/packet.cc index f2f7fd9b8..7a28fbf5b 100644 --- a/src/mem/packet.cc +++ b/src/mem/packet.cc @@ -53,14 +53,14 @@ #include #include #include +#include +#include #include "base/cprintf.hh" #include "base/logging.hh" #include "base/trace.hh" #include "mem/packet_access.hh" -using namespace std; - // The one downside to bitsets is that static initializers can get ugly. #define SET1(a1) (1 << (a1)) #define SET2(a1, a2) (SET1(a1) | SET1(a2)) @@ -260,7 +260,7 @@ Packet::checkFunctional(Printable *obj, Addr addr, bool is_secure, int size, std::max(val_start, func_start); if (isRead()) { - memcpy(getPtr() + func_offset, + std::memcpy(getPtr() + func_offset, _data + val_offset, overlap_size); @@ -288,7 +288,7 @@ Packet::checkFunctional(Printable *obj, Addr addr, bool is_secure, int size, return all_bytes_valid; } else if (isWrite()) { - memcpy(_data + val_offset, + std::memcpy(_data + val_offset, getConstPtr() + func_offset, overlap_size); } else { @@ -357,7 +357,8 @@ Packet::setUintX(uint64_t w, ByteOrder endian) } void -Packet::print(ostream &o, const int verbosity, const string &prefix) const +Packet::print(std::ostream &o, const int verbosity, + const std::string &prefix) const { ccprintf(o, "%s%s [%x:%x]%s%s%s%s%s%s", prefix, cmdString(), getAddr(), getAddr() + getSize() - 1, @@ -371,13 +372,13 @@ Packet::print(ostream &o, const int verbosity, const string &prefix) const std::string Packet::print() const { - ostringstream str; + std::ostringstream str; print(str); return str.str(); } -Packet::PrintReqState::PrintReqState(ostream &_os, int _verbosity) - : curPrefixPtr(new string("")), os(_os), verbosity(_verbosity) +Packet::PrintReqState::PrintReqState(std::ostream &_os, int _verbosity) + : curPrefixPtr(new std::string("")), os(_os), verbosity(_verbosity) { labelStack.push_back(LabelStackEntry("", curPrefixPtr)); } @@ -390,16 +391,18 @@ Packet::PrintReqState::~PrintReqState() } Packet::PrintReqState:: -LabelStackEntry::LabelStackEntry(const string &_label, string *_prefix) +LabelStackEntry::LabelStackEntry(const std::string &_label, + std::string *_prefix) : label(_label), prefix(_prefix), labelPrinted(false) { } void -Packet::PrintReqState::pushLabel(const string &lbl, const string &prefix) +Packet::PrintReqState::pushLabel(const std::string &lbl, + const std::string &prefix) { labelStack.push_back(LabelStackEntry(lbl, curPrefixPtr)); - curPrefixPtr = new string(*curPrefixPtr); + curPrefixPtr = new std::string(*curPrefixPtr); *curPrefixPtr += prefix; }