Further small cleaning.

This commit is contained in:
jmsgrogan 2023-01-16 12:05:36 +00:00
parent dba6a91ec1
commit c81db288b0
5 changed files with 13 additions and 11 deletions

View file

@ -58,7 +58,7 @@ unsigned char ByteUtils::getLowerNBits(uint32_t input, unsigned num)
case 7:
return input & 0x7F;
case 8:
return input;
return static_cast<unsigned char>(input);
default:
return 0;
}

View file

@ -10,7 +10,7 @@
#include <fcntl.h>
#endif
void SharedMemory::allocate(const std::string& namePrefix, std::size_t size)
void SharedMemory::allocate(const std::string& namePrefix, std::size_t)
{
createFile(namePrefix);
@ -60,6 +60,8 @@ void SharedMemory::createFile(const std::string& namePrefix)
break;
}
} while (retries > 0 && errno == EEXIST);
#else
(void)(namePrefix);
#endif
}

View file

@ -30,8 +30,8 @@ void BitStream::write(uint32_t data)
void BitStream::writeWord(uint16_t data)
{
const auto byte0 = data >> 8;
const auto byte1 = (data << 8) >> 8;
const auto byte0 = static_cast<unsigned char>(data >> 8);
const auto byte1 = static_cast<unsigned char>((data << 8) >> 8);
writeByte(byte0);
writeByte(byte1);
}
@ -81,13 +81,13 @@ void BitStream::writeNBits(uint32_t data, unsigned length)
unsigned num_bytes = overshoot / 8;
for (unsigned idx=0; idx< num_bytes; idx++)
{
mCurrentByte = ByteUtils::getMBitsAtN(data, overshoot, idx*8 + num_left);
mCurrentByte = ByteUtils::getMBitsAtN(static_cast<unsigned char>(data), overshoot, idx*8 + num_left);
writeByte(mCurrentByte, false);
}
if (const auto remainder = overshoot % 8; remainder > 0)
{
mCurrentByte = ByteUtils::getMBitsAtN(data, remainder, num_bytes*8 + num_left);
mCurrentByte = ByteUtils::getMBitsAtN(static_cast<unsigned char>(data), remainder, num_bytes*8 + num_left);
mBitOffset = remainder;
}
else

View file

@ -12,7 +12,7 @@ bool InputBitStream::isFinished() const
return mStream->good();
}
std::vector<unsigned char> InputBitStream::peekNextNBytes(unsigned n) const
std::vector<unsigned char> InputBitStream::peekNextNBytes(unsigned) const
{
return {};
}
@ -29,7 +29,7 @@ std::optional<unsigned char> InputBitStream::readNextByte()
}
}
void InputBitStream::writeByte(unsigned char data, bool checkOverflow )
void InputBitStream::writeByte(unsigned char, bool)
{
}

View file

@ -12,7 +12,7 @@ bool OutputBitStream::isFinished() const
return true;
}
std::vector<unsigned char> OutputBitStream::peekNextNBytes(unsigned n) const
std::vector<unsigned char> OutputBitStream::peekNextNBytes(unsigned) const
{
return {};
}
@ -22,7 +22,7 @@ std::optional<unsigned char> OutputBitStream::readNextByte()
return std::nullopt;
}
void OutputBitStream::writeByte(unsigned char data, bool checkOverflow )
void OutputBitStream::writeByte(unsigned char data, bool)
{
(*mStream) << data;
}