Replace C casts with static and reinterpret casts in MC
This commit is contained in:
parent
086b406748
commit
4d86f0e3d9
6
deps/ox/src/ox/mc/read.hpp
vendored
6
deps/ox/src/ox/mc/read.hpp
vendored
@ -88,7 +88,7 @@ int MetalClawReader::op(const char*, ox::BString<L> *val) {
|
||||
// read the length
|
||||
size_t size = 0;
|
||||
if (m_buffIt + sizeof(StringLength) < m_buffLen) {
|
||||
size = ox::bigEndianAdapt(*((StringLength*) &m_buff[m_buffIt]));
|
||||
size = ox::bigEndianAdapt(*(reinterpret_cast<StringLength*>(&m_buff[m_buffIt])));
|
||||
m_buffIt += sizeof(StringLength);
|
||||
} else {
|
||||
err |= MC_BUFFENDED;
|
||||
@ -117,7 +117,7 @@ int MetalClawReader::readInteger(I *val) {
|
||||
int err = 0;
|
||||
if (m_fieldPresence.get(m_field)) {
|
||||
if (m_buffIt + sizeof(I) < m_buffLen) {
|
||||
*val = ox::bigEndianAdapt(*((I*) &m_buff[m_buffIt]));
|
||||
*val = ox::bigEndianAdapt(*(reinterpret_cast<I*>(&m_buff[m_buffIt])));
|
||||
m_buffIt += sizeof(I);
|
||||
} else {
|
||||
err = MC_BUFFENDED;
|
||||
@ -136,7 +136,7 @@ int MetalClawReader::op(const char*, T *val, size_t valLen) {
|
||||
// read the length
|
||||
size_t len = 0;
|
||||
if (m_buffIt + sizeof(ArrayLength) < m_buffLen) {
|
||||
len = ox::bigEndianAdapt(*((ArrayLength*) &m_buff[m_buffIt]));
|
||||
len = ox::bigEndianAdapt(*(reinterpret_cast<ArrayLength*>(&m_buff[m_buffIt])));
|
||||
m_buffIt += sizeof(ArrayLength);
|
||||
} else {
|
||||
err = MC_BUFFENDED;
|
||||
|
8
deps/ox/src/ox/mc/write.hpp
vendored
8
deps/ox/src/ox/mc/write.hpp
vendored
@ -75,7 +75,7 @@ int MetalClawWriter::op(const char*, ox::BString<L> *val) {
|
||||
// write the length
|
||||
typedef uint32_t StringLength;
|
||||
if (m_buffIt + sizeof(StringLength) + val->size() < m_buffLen) {
|
||||
*((StringLength*) &m_buff[m_buffIt]) = ox::bigEndianAdapt((StringLength) val->size());
|
||||
*(reinterpret_cast<StringLength*>(&m_buff[m_buffIt])) = ox::bigEndianAdapt(static_cast<StringLength>(val->size()));
|
||||
m_buffIt += sizeof(StringLength);
|
||||
|
||||
// write the string
|
||||
@ -97,7 +97,7 @@ int MetalClawWriter::op(const char*, T *val) {
|
||||
bool fieldSet = false;
|
||||
MetalClawWriter writer(m_buff + m_buffIt, m_buffLen - m_buffIt);
|
||||
err |= ioOp(&writer, val);
|
||||
if ((size_t) writer.m_fieldPresence.getMaxLen() < writer.m_buffIt) {
|
||||
if (static_cast<size_t>(writer.m_fieldPresence.getMaxLen()) < writer.m_buffIt) {
|
||||
m_buffIt += writer.m_buffIt;
|
||||
fieldSet = true;
|
||||
}
|
||||
@ -112,7 +112,7 @@ int MetalClawWriter::appendInteger(I val) {
|
||||
bool fieldSet = false;
|
||||
if (val) {
|
||||
if (m_buffIt + sizeof(I) < m_buffLen) {
|
||||
*((I*) &m_buff[m_buffIt]) = ox::bigEndianAdapt(val);
|
||||
*(reinterpret_cast<I*>(&m_buff[m_buffIt])) = ox::bigEndianAdapt(val);
|
||||
fieldSet = true;
|
||||
m_buffIt += sizeof(I);
|
||||
} else {
|
||||
@ -133,7 +133,7 @@ int MetalClawWriter::op(const char*, T *val, size_t len) {
|
||||
// write the length
|
||||
typedef uint32_t ArrayLength;
|
||||
if (m_buffIt + sizeof(ArrayLength) < m_buffLen) {
|
||||
*((ArrayLength*) &m_buff[m_buffIt]) = ox::bigEndianAdapt((ArrayLength) len);
|
||||
*reinterpret_cast<ArrayLength*>(&m_buff[m_buffIt]) = ox::bigEndianAdapt(static_cast<ArrayLength>(len));
|
||||
m_buffIt += sizeof(ArrayLength);
|
||||
} else {
|
||||
err = MC_BUFFENDED;
|
||||
|
Loading…
Reference in New Issue
Block a user