Updates from latest cppcheck
Signed-off-by: Zane Shelley <zshelle@us.ibm.com>
Change-Id: Ia9dd43ce762f613e35d07f3028a918bba6ac36ce
diff --git a/.gitignore b/.gitignore
index 59f76fd..82d41a6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
*.sw*
/build
/subprojects/googletest
+/cppcheck-temp
diff --git a/src/chip_data/hei_chip_data_stream.hpp b/src/chip_data/hei_chip_data_stream.hpp
index 1ca28af..cb3ed7d 100644
--- a/src/chip_data/hei_chip_data_stream.hpp
+++ b/src/chip_data/hei_chip_data_stream.hpp
@@ -71,7 +71,8 @@
HEI_ASSERT((iv_currentIndex + i_size) <= iv_bufferSize);
// Copy the buffer.
- memcpy(o_buf, (char*)iv_buffer + iv_currentIndex, i_size);
+ memcpy(o_buf, static_cast<const char*>(iv_buffer) + iv_currentIndex,
+ i_size);
// Increment the curent index for the next piece of data.
iv_currentIndex += i_size;
diff --git a/src/hei_chip.hpp b/src/hei_chip.hpp
index cc8995f..3ef83aa 100644
--- a/src/hei_chip.hpp
+++ b/src/hei_chip.hpp
@@ -66,14 +66,14 @@
* purpose is to eventually get passed back to the user application with
* information associated with each chip.
*/
- const void* iv_chip;
+ const void* iv_chip = nullptr;
/**
* When doing analysis on a chip, the isolator will need to know the chip
* type in order to look up the correct information from the Chip Data
* Files.
*/
- ChipType_t iv_type;
+ ChipType_t iv_type = 0;
}; // end class Chip
diff --git a/src/hei_signature.hpp b/src/hei_signature.hpp
index 92aaa3f..dbf63a8 100644
--- a/src/hei_signature.hpp
+++ b/src/hei_signature.hpp
@@ -50,11 +50,13 @@
Signature& operator=(const Signature&) = default;
private:
- Chip iv_chip; ///< Chip containing this register.
- NodeId_t iv_id; ///< Node ID.
- Instance_t iv_instance; ///< Instance of this register.
- BitPosition_t iv_bit; ///< Target bit within this register.
- AttentionType_t iv_attnType; ///< Attention type reported by this bit.
+ Chip iv_chip; ///< Chip containing this register.
+ NodeId_t iv_id = 0; ///< Node ID.
+ Instance_t iv_instance = 0; ///< Instance of this register.
+ BitPosition_t iv_bit = 0; ///< Target bit within this register.
+
+ /** Attention type reported by this bit. */
+ AttentionType_t iv_attnType = ATTN_TYPE_CHECKSTOP;
public: // Member functions
/** @return The chip containing this register. */
diff --git a/src/register/hei_hardware_register.cpp b/src/register/hei_hardware_register.cpp
index 78e92a9..b6a2d12 100644
--- a/src/register/hei_hardware_register.cpp
+++ b/src/register/hei_hardware_register.cpp
@@ -147,9 +147,9 @@
void HardwareRegister::Cache::flush()
{
// Delete all of the BitStrings.
- for (auto& chipPair : iv_cache)
+ for (const auto& chipPair : iv_cache)
{
- for (auto& hwRegPair : chipPair.second)
+ for (const auto& hwRegPair : chipPair.second)
{
delete hwRegPair.second;
}
diff --git a/src/register/hei_hardware_register.hpp b/src/register/hei_hardware_register.hpp
index 5147edf..be9fdc1 100644
--- a/src/register/hei_hardware_register.hpp
+++ b/src/register/hei_hardware_register.hpp
@@ -105,9 +105,6 @@
/** @return The address of this register. */
virtual RegisterAddress_t getAddress() const = 0;
- /** @return The size (in bytes) of this register. */
- virtual size_t getSize() const = 0;
-
public: // Operators
/** @brief Equals operator. */
bool operator==(const HardwareRegister& i_r) const
@@ -165,7 +162,7 @@
public:
/** Function overloaded from parent Register class. */
- const BitString* getBitString(const Chip& i_chip) const;
+ const BitString* getBitString(const Chip& i_chip) const override;
/**
* @brief Reads a register from hardware via the user interface APIs.
diff --git a/src/register/hei_scom_register.hpp b/src/register/hei_scom_register.hpp
index 040bd4f..da0eee9 100644
--- a/src/register/hei_scom_register.hpp
+++ b/src/register/hei_scom_register.hpp
@@ -41,19 +41,19 @@
public: // Accessor functions
/** Function overloaded from parent HardwareRegister class. */
- RegisterType_t getType() const
+ RegisterType_t getType() const override
{
return REG_TYPE_SCOM;
}
/** Function overloaded from parent HardwareRegister class. */
- RegisterAddress_t getAddress() const
+ RegisterAddress_t getAddress() const override
{
return static_cast<RegisterAddress_t>(iv_address);
}
/** Function overloaded from parent HardwareRegister class. */
- size_t getSize() const
+ size_t getSize() const override
{
return 8;
}
@@ -106,19 +106,19 @@
public: // Accessor functions
/** Function overloaded from parent HardwareRegister class. */
- RegisterType_t getType() const
+ RegisterType_t getType() const override
{
return REG_TYPE_ID_SCOM;
}
/** Function overloaded from parent HardwareRegister class. */
- RegisterAddress_t getAddress() const
+ RegisterAddress_t getAddress() const override
{
return static_cast<RegisterAddress_t>(iv_address);
}
/** Function overloaded from parent HardwareRegister class. */
- size_t getSize() const
+ size_t getSize() const override
{
return 8; // See note in class documentation.
}
diff --git a/src/util/hei_bit_string.cpp b/src/util/hei_bit_string.cpp
index 88eb7bb..066cde9 100644
--- a/src/util/hei_bit_string.cpp
+++ b/src/util/hei_bit_string.cpp
@@ -422,7 +422,7 @@
o_relPos = (i_absPos + iv_offset) % UINT8_BIT_LEN;
- return ((uint8_t*)iv_bufAddr + ((i_absPos + iv_offset) / UINT8_BIT_LEN));
+ return (iv_bufAddr + ((i_absPos + iv_offset) / UINT8_BIT_LEN));
}
//##############################################################################
@@ -439,7 +439,7 @@
BitStringBuffer::~BitStringBuffer()
{
- delete[](uint8_t*) getBufAddr();
+ delete[] getBufAddr();
}
//------------------------------------------------------------------------------
@@ -472,7 +472,7 @@
{
// The initBuffer() function will deallocate the buffer as well, however we
// also need to deallocate the buffer here before we set the length.
- delete[](uint8_t*) getBufAddr();
+ delete[] getBufAddr();
setBufAddr(nullptr);
setBitLen(i_bs.getBitLen());
@@ -493,7 +493,7 @@
{
// The initBuffer() function will deallocate the buffer as well, however
// we also need to deallocate the buffer here before we set the length.
- delete[](uint8_t*) getBufAddr();
+ delete[] getBufAddr();
setBufAddr(nullptr);
setBitLen(i_bsb.getBitLen());
@@ -512,7 +512,7 @@
void BitStringBuffer::initBuffer()
{
// Deallocate the current buffer.
- delete[](uint8_t*) getBufAddr();
+ delete[] getBufAddr();
// create new buffer, initialized to 0's
setBufAddr(new uint8_t[getMinBytes(getBitLen())]());
diff --git a/src/util/hei_bit_string.hpp b/src/util/hei_bit_string.hpp
index 59369b7..5a1ad0f 100644
--- a/src/util/hei_bit_string.hpp
+++ b/src/util/hei_bit_string.hpp
@@ -75,7 +75,8 @@
* to allocate sufficient memory space for this bit string.
*/
BitString(uint64_t i_bitLen, void* i_bufAddr, uint64_t i_offset = 0) :
- iv_bitLen(i_bitLen), iv_bufAddr(i_bufAddr), iv_offset(i_offset)
+ iv_bitLen(i_bitLen), iv_bufAddr(static_cast<uint8_t*>(i_bufAddr)),
+ iv_offset(i_offset)
{}
/** @brief Destructor */
@@ -89,7 +90,7 @@
/** @return The address of the bit string buffer. Note that this may
* return nullptr. */
- void* getBufAddr() const
+ uint8_t* getBufAddr() const
{
return iv_bufAddr;
}
@@ -391,7 +392,7 @@
*/
void setBufAddr(void* i_newBufAddr)
{
- iv_bufAddr = i_newBufAddr;
+ iv_bufAddr = static_cast<uint8_t*>(i_newBufAddr);
}
/** @param i_newBitLen The new bit length of this bit string buffer. */
@@ -414,9 +415,9 @@
uint8_t* getRelativePosition(uint64_t& o_relPos, uint64_t i_absPos) const;
private:
- uint64_t iv_bitLen; ///< The bit length of this buffer.
- void* iv_bufAddr; ///< The beginning address of this buffer.
- uint64_t iv_offset; ///< Start position offset
+ uint64_t iv_bitLen; ///< The bit length of this buffer.
+ uint8_t* iv_bufAddr; ///< The beginning address of this buffer.
+ uint64_t iv_offset; ///< Start position offset
};
//##############################################################################