Daniel Carvalho has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/44366 )
Change subject: dev: Fix compilation errors
......................................................................
dev: Fix compilation errors
'backing' was initialized after being used.
'buffer' was initialized after its data() was used
by the constructor.
Change-Id: I0f8d0f6efb5d4b7abc5fc6c2c3ecca2c9b0a2eaf
Signed-off-by: Daniel R. Carvalho <[email protected]>
---
M src/dev/reg_bank.hh
M src/dev/reg_bank.test.cc
2 files changed, 18 insertions(+), 7 deletions(-)
diff --git a/src/dev/reg_bank.hh b/src/dev/reg_bank.hh
index 7abe02c..3b6b036 100644
--- a/src/dev/reg_bank.hh
+++ b/src/dev/reg_bank.hh
@@ -413,6 +413,14 @@
RegisterBase(new_name, bytes), _ptr(ptr)
{}
+ void
+ setBuffer(void *buf)
+ {
+ assert(_ptr == nullptr);
+ assert(buf != nullptr);
+ _ptr = buf;
+ }
+
void write(const void *buf) override { write(buf, 0,
this->size()); }
void
write(const void *buf, off_t offset, size_t bytes) override
@@ -442,8 +450,10 @@
std::array<uint8_t, BufBytes> buffer;
RegisterLBuf(const std::string &new_name) :
- RegisterBuf(new_name, buffer.data(), BufBytes)
- {}
+ RegisterBuf(new_name, nullptr, BufBytes)
+ {
+ this->setBuffer(buffer.data());
+ }
void
serialize(std::ostream &os) const override
diff --git a/src/dev/reg_bank.test.cc b/src/dev/reg_bank.test.cc
index 78fc9e6..088f1f3 100644
--- a/src/dev/reg_bank.test.cc
+++ b/src/dev/reg_bank.test.cc
@@ -244,16 +244,17 @@
protected:
static constexpr size_t RegSize = 4;
- RegisterBankLE::RegisterBuf reg;
-
std::array<uint8_t, RegSize * 3> buf;
std::array<uint8_t, RegSize * 3> backing;
+ RegisterBankLE::RegisterBuf reg;
+
public:
- RegisterBufTest() : reg("buf_reg", backing.data() + RegSize, RegSize),
- buf{0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc},
+ RegisterBufTest()
+ : buf{0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc},
backing{0x10, 0x20, 0x30, 0x40, 0x50, 0x60,
- 0x70, 0x80, 0x90, 0xa0, 0xb0, 0xc0}
+ 0x70, 0x80, 0x90, 0xa0, 0xb0, 0xc0},
+ reg("buf_reg", backing.data() + RegSize, RegSize)
{}
};
// Needed by C++14 and lower
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/44366
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I0f8d0f6efb5d4b7abc5fc6c2c3ecca2c9b0a2eaf
Gerrit-Change-Number: 44366
Gerrit-PatchSet: 1
Gerrit-Owner: Daniel Carvalho <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s