Lots of various changes suggested by the code analysis tools.

Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
This commit is contained in:
Adrian Conlon
2018-11-27 22:36:54 +00:00
parent 555423d10a
commit a673a64c3f
14 changed files with 87 additions and 83 deletions
+1 -1
View File
@@ -4,5 +4,5 @@
#include <stdexcept>
uint8_t& EightBit::Memory::reference(uint16_t) {
throw new std::logic_error("Reference operation not allowed.");
throw std::logic_error("Reference operation not allowed.");
}
+4 -4
View File
@@ -41,7 +41,7 @@ void EightBit::Rom::poke(const uint16_t address, const uint8_t value) {
BYTES()[address] = value;
}
EightBit::Rom::Rom(const size_t size) noexcept
EightBit::Rom::Rom(const size_t size)
: m_bytes(size) {}
size_t EightBit::Rom::size() const {
@@ -49,18 +49,18 @@ size_t EightBit::Rom::size() const {
}
int EightBit::Rom::load(std::ifstream& file, const int writeOffset, const int readOffset, const int limit) {
const auto maximumSize = (int)size() - writeOffset;
const auto maximumSize = size() - writeOffset;
return load(file, m_bytes, writeOffset, readOffset, limit, maximumSize);
}
int EightBit::Rom::load(const std::string& path, const int writeOffset, const int readOffset, const int limit) {
const auto maximumSize = (int)size() - writeOffset;
const auto maximumSize = size() - writeOffset;
return load(path, m_bytes, writeOffset, readOffset, limit, maximumSize);
}
int EightBit::Rom::load(const std::vector<uint8_t>& bytes, const int writeOffset, const int readOffset, int limit) {
if (limit < 0)
limit = (int)bytes.size() - readOffset;
limit = bytes.size() - readOffset;
std::copy(bytes.cbegin() + readOffset, bytes.cbegin() + limit, m_bytes.begin() + writeOffset);
return limit;
}
+4 -4
View File
@@ -13,17 +13,17 @@ uint8_t EightBit::UnusedMemory::peek(uint16_t) const {
}
int EightBit::UnusedMemory::load(std::ifstream&, int, int, int) {
throw new std::logic_error("load operation not allowed.");
throw std::logic_error("load operation not allowed.");
}
int EightBit::UnusedMemory::load(const std::string&, int, int, int) {
throw new std::logic_error("load operation not allowed.");
throw std::logic_error("load operation not allowed.");
}
int EightBit::UnusedMemory::load(const std::vector<uint8_t>&, int, int, int) {
throw new std::logic_error("load operation not allowed.");
throw std::logic_error("load operation not allowed.");
}
void EightBit::UnusedMemory::poke(uint16_t, uint8_t) {
throw new std::logic_error("Poke operation not allowed.");
throw std::logic_error("Poke operation not allowed.");
}