Use explicit casting when truncating long numbers, so that it will build in Xcode

This commit is contained in:
David Novak 2019-06-10 16:08:46 -04:00
parent f80b8a8b7a
commit d7bf5a2eb6
4 changed files with 17 additions and 17 deletions

View File

@ -81,7 +81,7 @@ void DefaultLogger::log(v_int32 priority, const std::string& tag, const std::str
}
if(m_config.timeFormat) {
time_t seconds = std::chrono::duration_cast<std::chrono::seconds>(time).count();
time_t seconds = (time_t)std::chrono::duration_cast<std::chrono::seconds>(time).count();
struct tm now;
localtime_r(&seconds, &now);
std::cout << std::put_time(&now, m_config.timeFormat);

View File

@ -84,7 +84,7 @@ data::v_io_size FIFOBuffer::read(void *data, data::v_io_size count) {
if(size > count) {
size = count;
}
std::memcpy(data, &m_buffer[m_readPosition], size);
std::memcpy(data, &m_buffer[m_readPosition], (size_t)size);
m_readPosition += size;
if(m_readPosition == m_writePosition) {
m_canRead = false;
@ -95,18 +95,18 @@ data::v_io_size FIFOBuffer::read(void *data, data::v_io_size count) {
auto size = m_bufferSize - m_readPosition;
if(size > count){
std::memcpy(data, &m_buffer[m_readPosition], count);
std::memcpy(data, &m_buffer[m_readPosition], (size_t)count);
m_readPosition += count;
return count;
}
std::memcpy(data, &m_buffer[m_readPosition], size);
std::memcpy(data, &m_buffer[m_readPosition], (size_t)size);
auto size2 = m_writePosition;
if(size2 > count - size) {
size2 = count - size;
}
std::memcpy(&((p_char8) data)[size], m_buffer, size2);
std::memcpy(&((p_char8) data)[size], m_buffer, (size_t)size2);
m_readPosition = size2;
if(m_readPosition == m_writePosition) {
m_canRead = false;
@ -135,7 +135,7 @@ data::v_io_size FIFOBuffer::write(const void *data, data::v_io_size count) {
if(size > count) {
size = count;
}
std::memcpy(&m_buffer[m_writePosition], data, size);
std::memcpy(&m_buffer[m_writePosition], data, (size_t)size);
m_writePosition += size;
return size;
}
@ -143,18 +143,18 @@ data::v_io_size FIFOBuffer::write(const void *data, data::v_io_size count) {
auto size = m_bufferSize - m_writePosition;
if(size > count){
std::memcpy(&m_buffer[m_writePosition], data, count);
std::memcpy(&m_buffer[m_writePosition], data, (size_t)count);
m_writePosition += count;
return count;
}
std::memcpy(&m_buffer[m_writePosition], data, size);
std::memcpy(&m_buffer[m_writePosition], data, (size_t)size);
auto size2 = m_readPosition;
if(size2 > count - size) {
size2 = count - size;
}
std::memcpy(m_buffer, &((p_char8) data)[size], size2);
std::memcpy(m_buffer, &((p_char8) data)[size], (size_t)size2);
m_writePosition = size2;
return (size + size2);

View File

@ -71,7 +71,7 @@ data::v_io_size ChunkedBuffer::writeToEntry(ChunkEntry* entry,
outChunkPos = 0;
return CHUNK_ENTRY_SIZE;
} else {
std::memcpy(entry->chunk, data, count);
std::memcpy(entry->chunk, data, (size_t)count);
outChunkPos = count;
return count;
}
@ -84,11 +84,11 @@ data::v_io_size ChunkedBuffer::writeToEntryFrom(ChunkEntry* entry,
data::v_io_size& outChunkPos) {
data::v_io_size spaceLeft = CHUNK_ENTRY_SIZE - inChunkPos;
if(count >= spaceLeft){
std::memcpy(&((p_char8) entry->chunk)[inChunkPos], data, spaceLeft);
std::memcpy(&((p_char8) entry->chunk)[inChunkPos], data, (size_t)spaceLeft);
outChunkPos = 0;
return spaceLeft;
} else {
std::memcpy(&((p_char8) entry->chunk)[inChunkPos], data, count);
std::memcpy(&((p_char8) entry->chunk)[inChunkPos], data, (size_t)count);
outChunkPos = inChunkPos + count;
return count;
}
@ -179,7 +179,7 @@ data::v_io_size ChunkedBuffer::readSubstring(void *buffer,
if(firstChunk != lastChunk){
data::v_io_size countToCopy = CHUNK_ENTRY_SIZE - firstChunkPos;
std::memcpy(buffer, &((p_char8)firstChunk->chunk)[firstChunkPos], countToCopy);
std::memcpy(buffer, &((p_char8)firstChunk->chunk)[firstChunkPos], (size_t)countToCopy);
bufferPos += countToCopy;
auto curr = firstChunk->next;
@ -190,11 +190,11 @@ data::v_io_size ChunkedBuffer::readSubstring(void *buffer,
curr = curr->next;
}
std::memcpy(&((p_char8)buffer)[bufferPos], lastChunk->chunk, lastChunkPos);
std::memcpy(&((p_char8)buffer)[bufferPos], lastChunk->chunk, (size_t)lastChunkPos);
} else {
data::v_io_size countToCopy = lastChunkPos - firstChunkPos;
std::memcpy(buffer, &((p_char8)firstChunk->chunk)[firstChunkPos], countToCopy);
std::memcpy(buffer, &((p_char8)firstChunk->chunk)[firstChunkPos], (size_t)countToCopy);
}
return countToRead;

View File

@ -49,7 +49,7 @@ data::v_io_size Connection::write(const void *buff, data::v_io_size count){
#ifdef MSG_NOSIGNAL
flags |= MSG_NOSIGNAL;
#endif
auto result = ::send(m_handle, buff, count, flags);
auto result = ::send(m_handle, buff, (size_t)count, flags);
if(result <= 0) {
auto e = errno;
@ -68,7 +68,7 @@ data::v_io_size Connection::write(const void *buff, data::v_io_size count){
data::v_io_size Connection::read(void *buff, data::v_io_size count){
errno = 0;
auto result = ::read(m_handle, buff, count);
auto result = ::read(m_handle, buff, (size_t)count);
if(result <= 0) {
auto e = errno;
if(e == EAGAIN || e == EWOULDBLOCK){