From bddaf98342a461f4e02389d4db390098fb423fbf Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Sat, 9 Aug 2014 19:23:48 -0700 Subject: Fixing even more warnings. --- src/BLua.cc | 16 ++++++++++------ src/BString.cc | 16 ++++++++-------- src/BWebSocket.cc | 6 +++--- src/Base64.cc | 6 +++--- src/BigInt.cc | 14 ++++++++------ src/Buffer.cc | 2 +- src/Handle.cc | 31 +++++++++++++++---------------- src/HttpServer.cc | 46 ++++++++++++++++++++++++---------------------- src/Input.cc | 2 +- src/LuaBigInt.cc | 16 ++++++++-------- src/LuaHandle.cc | 16 ++++++++-------- src/Output.cc | 2 +- src/Selectable.cc | 4 ++-- 13 files changed, 92 insertions(+), 85 deletions(-) (limited to 'src') diff --git a/src/BLua.cc b/src/BLua.cc index b111218..5b3df8b 100644 --- a/src/BLua.cc +++ b/src/BLua.cc @@ -17,6 +17,8 @@ extern "C" { #include } +#undef max + #ifndef BUFFERSIZE #define BUFFERSIZE 2048 #endif @@ -68,7 +70,7 @@ int Balau::LuaStatics::hex(lua_State * __L) { if (((n != 1) && (n != 2)) || !L.isnumber(1) || ((n == 2) && !L.isstring(2))) L.error("Incorrect arguments to function `hex'"); - x = L.tonumber(1); + x = (int) L.tonumber(1); String fmt = n == 2 ? L.tostring() : "%02x"; r.set(fmt.to_charp(), x); @@ -1081,19 +1083,21 @@ Balau::LuaObjectBase * Balau::LuaObjectFactory::getMeInternal(Lua & L, int i) { return o; } -void Balau::LuaObjectFactory::pushMethod(Lua & L, const char * s, int strSize, lua_CFunction f, int upvalues) { +void Balau::LuaObjectFactory::pushMethod(Lua & L, const char * s, size_t strSize, lua_CFunction f, int upvalues) { + AAssert(strSize < std::numeric_limits::max(), "string size too large! (%zu)", strSize); if (upvalues == 0) { - L.push(s, strSize); + L.push(s, (int) strSize); L.push(f); } else { L.push(f, upvalues); - L.push(s, strSize); + L.push(s, (int) strSize); L.insert(-2); } L.settable(-3, true); } -void Balau::LuaObjectFactory::pushMeta(Lua & L, const char * s, int strSize, lua_CFunction f, int upvalues) { +void Balau::LuaObjectFactory::pushMeta(Lua & L, const char * s, size_t strSize, lua_CFunction f, int upvalues) { + AAssert(strSize < std::numeric_limits::max(), "string size too large! (%zu)", strSize); if (!L.getmetatable()) L.newtable(); if (upvalues == 0) { @@ -1101,7 +1105,7 @@ void Balau::LuaObjectFactory::pushMeta(Lua & L, const char * s, int strSize, lua L.push(f); } else { L.push(f, upvalues); - L.push(s, strSize); + L.push(s, (int) strSize); L.insert(-2); } L.settable(); diff --git a/src/BString.cc b/src/BString.cc index f5bcfee..d372985 100644 --- a/src/BString.cc +++ b/src/BString.cc @@ -41,7 +41,7 @@ Balau::String & Balau::String::append(const char * fmt, va_list ap) { } int Balau::String::strchrcnt(char c) const { - unsigned int l = length(); + size_t l = length(); int r = 0; const char * buffer = data(); @@ -53,10 +53,10 @@ int Balau::String::strchrcnt(char c) const { } Balau::String & Balau::String::do_ltrim() { - unsigned int l = length(), s = 0; + size_t l = length(), s = 0; const char * buffer = data(); - for (unsigned int i = 0; i < l; i++) + for (size_t i = 0; i < l; i++) if (isspace(buffer[i])) s++; else @@ -68,7 +68,7 @@ Balau::String & Balau::String::do_ltrim() { } Balau::String & Balau::String::do_rtrim() { - unsigned int i, l = length(), p = l; + size_t i, l = length(), p = l; const char * buffer = data(); if (l == 0) @@ -89,18 +89,18 @@ Balau::String & Balau::String::do_rtrim() { } Balau::String & Balau::String::do_upper() { - unsigned int l = length(); + size_t l = length(); - for (unsigned int i = 0; i < l; i++) + for (size_t i = 0; i < l; i++) (*this)[i] = toupper((*this)[i]); return *this; } Balau::String & Balau::String::do_lower() { - unsigned int l = length(); + size_t l = length(); - for (unsigned int i = 0; i < l; i++) + for (size_t i = 0; i < l; i++) (*this)[i] = tolower((*this)[i]); return *this; diff --git a/src/BWebSocket.cc b/src/BWebSocket.cc index 339ac3a..e6c9c1d 100644 --- a/src/BWebSocket.cc +++ b/src/BWebSocket.cc @@ -21,7 +21,7 @@ Balau::WebSocketFrame::WebSocketFrame(const uint8_t * data, size_t len, uint8_t maskPtr = m_data + 2; } else if (m_len < 65536) { m_data[1] |= 126; - m_data[2] = m_len >> 8; + m_data[2] = (m_len >> 8) & 0xff; m_data[3] = m_len & 0xff; maskPtr = m_data + 4; } else { @@ -61,7 +61,7 @@ void Balau::WebSocketFrame::send(Balau::IO socket) { size_t totalLen = m_headerSize + m_len; if (m_mask) { - for (int i = m_headerSize; i < totalLen; i++) { + for (size_t i = m_headerSize; i < totalLen; i++) { m_data[i] ^= m_mask >> 24; m_mask = rotate(m_mask); } @@ -218,7 +218,7 @@ void Balau::WebSocketWorker::Do() { *payloadP = (uint8_t *) realloc(*payloadP, *totalLenP + (*opcodeP == OPCODE_TEXT ? 1 : 0)); case READ_PL: while (*remainingBytesP) { - int r = m_socket->read(*payloadP + *totalLenP - *remainingBytesP, *remainingBytesP); + ssize_t r = m_socket->read(*payloadP + *totalLenP - *remainingBytesP, *remainingBytesP); if (m_socket->isClosed()) return; if (r < 0) diff --git a/src/Base64.cc b/src/Base64.cc index 06a730d..95b3b63 100644 --- a/src/Base64.cc +++ b/src/Base64.cc @@ -34,7 +34,7 @@ void Balau::Base64::encode_block(unsigned char in_tab[3], int len, char out[5]) Balau::String Balau::Base64::encode(const uint8_t * data, int stream_size) { String encoded; - encoded.reserve(stream_size * ratio + 1); + encoded.reserve((size_t) (stream_size * ratio + 1)); unsigned char in_tab[3]; int len, i, s_pos; @@ -86,8 +86,8 @@ int Balau::Base64::decode_block(char s1, char s2, char s3, char s4, unsigned cha return len; } -int Balau::Base64::decode(const String & str_in, uint8_t * data_out, size_t outLen) { - int s_len = str_in.strlen(), len = 0, i, t_len, idx; +ssize_t Balau::Base64::decode(const String & str_in, uint8_t * data_out, size_t outLen) { + size_t s_len = str_in.strlen(), len = 0, i, t_len, idx; char s1, s2, s3, s4; unsigned char t_out[3]; unsigned char * p = data_out; diff --git a/src/BigInt.cc b/src/BigInt.cc index 3588e06..731b7ff 100644 --- a/src/BigInt.cc +++ b/src/BigInt.cc @@ -123,7 +123,7 @@ void Balau::BigInt::set(double v) throw (GeneralException) { if (mp_set_int((mp_int *) m_bi, 0) != MP_OKAY) throw GeneralException("Error while calling mp_set_init"); - for (e -= 1.0; e > 0.0; e -= 1.0) { + for (e--; e > 0; e--) { f *= 2.0; if (f >= 1.0) { operator+=(1); @@ -177,7 +177,7 @@ int64_t Balau::BigInt::to_int64() const throw (GeneralException) { uint32_t Balau::BigInt::to_uint32() const throw (GeneralException) { if (mp_count_bits((mp_int *) m_bi) > 32) throw GeneralException("BigInt too big to fit in a uint32"); - uint64_t v = 0; + uint32_t v = 0; int shift = 0; int digit = 0; while (shift <= 32) { @@ -189,8 +189,8 @@ uint32_t Balau::BigInt::to_uint32() const throw (GeneralException) { int32_t Balau::BigInt::to_int32() const throw (GeneralException) { if (mp_count_bits((mp_int *) m_bi) > 31) - throw GeneralException("BigInt too big to fit in a uint32"); - int64_t v = 0; + throw GeneralException("BigInt too big to fit in a int32"); + int32_t v = 0; int shift = 0; int digit = 0; while (shift <= 31) { @@ -632,8 +632,9 @@ void Balau::BigInt::exportUBin(void * _buf) const throw (GeneralException) { void Balau::BigInt::importBin(const void * _buf, size_t size) throw (GeneralException) { unsigned char * buf = (unsigned char *) _buf; + AAssert(size < std::numeric_limits::max(), "BigInt::importBin(%p, %zu): size too big", _buf, size); bool isNeg = buf[0] != 0; - if (mp_read_unsigned_bin((mp_int *) m_bi, buf + 1, size - 1) != MP_OKAY) + if (mp_read_unsigned_bin((mp_int *) m_bi, buf + 1, (unsigned long) size - 1) != MP_OKAY) throw GeneralException("Error while calling mp_read_unsigned_bin"); if (isNeg) do_neg(); @@ -641,7 +642,8 @@ void Balau::BigInt::importBin(const void * _buf, size_t size) throw (GeneralExce void Balau::BigInt::importUBin(const void * _buf, size_t size) throw (GeneralException) { unsigned char * buf = (unsigned char *)_buf; - if (mp_read_unsigned_bin((mp_int *) m_bi, buf, size) != MP_OKAY) + AAssert(size < std::numeric_limits::max(), "BigInt::importBin(%p, %zu): size too big", _buf, size); + if (mp_read_unsigned_bin((mp_int *)m_bi, buf, (unsigned long) size) != MP_OKAY) throw GeneralException("Error while calling mp_read_unsigned_bin"); } diff --git a/src/Buffer.cc b/src/Buffer.cc index b4dfbec..766206b 100644 --- a/src/Buffer.cc +++ b/src/Buffer.cc @@ -22,7 +22,7 @@ ssize_t Balau::Buffer::read(void * buf, size_t count) throw (GeneralException) { off64_t cursor = rtell(); if (cursor >= m_bufSize) return 0; - off64_t avail = m_bufSize - cursor; + size_t avail = m_bufSize - cursor; if (count > avail) count = avail; diff --git a/src/Handle.cc b/src/Handle.cc index e75edbb..e73d2fc 100644 --- a/src/Handle.cc +++ b/src/Handle.cc @@ -102,30 +102,29 @@ ssize_t Balau::Handle::forceWrite(const void * _buf, size_t count, Events::BaseE template Balau::Future genericRead(Balau::IO t) { - std::shared_ptr b(new T); - int c = 0; + T b; + size_t c = 0; return Balau::Future([t, b, c]() mutable { do { - int r = t->read(((uint8_t *) b.get()) + c, sizeof(T) - c); + ssize_t r = t->read(((uint8_t *) &b) + c, sizeof(T) - c); + AAssert(r >= 0, "genericRead got an error: %zi", r); c += r; - } while (c < sizeof(T)); - return *b; + } while ((c < sizeof(T)) && !t->isEOF()); + return b; }); } template Balau::Future genericReadBE(Balau::IO t) { - std::shared_ptr b(new T); - int c = 0; - *b.get() = 0; + T b; + size_t c = sizeof(T); return Balau::Future([t, b, c]() mutable { do { - uint8_t v = t->readU8().get(); - *b.get() <<= 8; - *b.get() += v; - c++; - } while (c < sizeof(T)); - return *b; + ssize_t r = t->read(((uint8_t *) &b) + c - 1, 1); + AAssert(r >= 0, "genericReadBE got an error: %zi", r); + c -= r; + } while (c && !t->isEOF()); + return b; }); } @@ -186,10 +185,10 @@ Balau::Future Balau::Handle::readBEI64() { return genericReadBE Balau::Future genericWrite(Balau::IO t, T val) { std::shared_ptr b(new T(val)); - int c = 0; + size_t c = 0; return Balau::Future([t, b, c]() mutable { do { - int r = t->write(((uint8_t *) b.get()) + c, sizeof(T)); + ssize_t r = t->write(((uint8_t *) b.get()) + c, sizeof(T)); c += r; } while (c < sizeof(T)); }); diff --git a/src/HttpServer.cc b/src/HttpServer.cc index fe95edb..b0d4d2a 100644 --- a/src/HttpServer.cc +++ b/src/HttpServer.cc @@ -148,7 +148,7 @@ Balau::String Balau::HttpWorker::httpUnescape(const char * in) { String r; const char * p; char hexa[3]; - char out; + uint8_t out; for (p = in; *p; p++) { switch (*p) { @@ -163,8 +163,8 @@ Balau::String Balau::HttpWorker::httpUnescape(const char * in) { if (!hexa[1]) return r; hexa[2] = 0; - out = strtol(hexa, NULL, 16); - r += String(&out, 1); + out = (uint8_t) strtol(hexa, NULL, 16); + r += String((char *) &out, 1); break; default: r += String(p, 1); @@ -284,66 +284,67 @@ bool Balau::HttpWorker::handleClient() { if (!gotFirst) { gotFirst = true; - int urlBegin = 0; + size_t urlBegin = 0; + size_t lineLen = line.strlen(); // first line is in the form of METHOD URL HTTP/xxx switch(line[0]) { case 'G': - if ((line[1] == 'E') && (line[2] == 'T') && (line[3] == ' ')) { + if ((lineLen >= 5) && (line[1] == 'E') && (line[2] == 'T') && (line[3] == ' ')) { urlBegin = 4; method = Http::GET; } break; case 'H': - if ((line[1] == 'E') && (line[2] == 'A') && (line[3] == 'D') && (line[4] == ' ')) { + if ((lineLen >= 6) && (line[1] == 'E') && (line[2] == 'A') && (line[3] == 'D') && (line[4] == ' ')) { urlBegin = 5; method = Http::HEAD; } break; case 'P': - if ((line[1] == 'O') && (line[2] == 'S') && (line[3] == 'T') && (line[4] == ' ')) { + if ((lineLen >= 6) && (line[1] == 'O') && (line[2] == 'S') && (line[3] == 'T') && (line[4] == ' ')) { urlBegin = 5; method = Http::POST; - } else if ((line[1] == 'U') && (line[2] == 'T') && (line[3] == ' ')) { + } else if ((lineLen >= 5) && (line[1] == 'U') && (line[2] == 'T') && (line[3] == ' ')) { urlBegin = 4; method = Http::PUT; - } else if ((line[1] == 'R') && (line[2] == 'O') && (line[3] == 'P') && (line[4] == 'F') && (line[5] == 'I') && (line[6] == 'N') && (line[7] == 'D') && (line[8] == ' ')) { + } else if ((lineLen >= 10) && (line[1] == 'R') && (line[2] == 'O') && (line[3] == 'P') && (line[4] == 'F') && (line[5] == 'I') && (line[6] == 'N') && (line[7] == 'D') && (line[8] == ' ')) { urlBegin = 9; method = Http::PROPFIND; } break; case 'D': - if ((line[1] == 'E') && (line[2] == 'L') && (line[3] == 'E') && (line[4] == 'T') && (line[5] == 'E') && (line[6] == ' ')) { + if ((lineLen >= 8) && (line[1] == 'E') && (line[2] == 'L') && (line[3] == 'E') && (line[4] == 'T') && (line[5] == 'E') && (line[6] == ' ')) { urlBegin = 7; method = Http::DELETE; } break; case 'T': - if ((line[1] == 'R') && (line[2] == 'A') && (line[3] == 'C') && (line[4] == 'E') && (line[5] == ' ')) { + if ((lineLen >= 7) && (line[1] == 'R') && (line[2] == 'A') && (line[3] == 'C') && (line[4] == 'E') && (line[5] == ' ')) { urlBegin = 6; method = Http::TRACE; } break; case 'O': - if ((line[1] == 'P') && (line[2] == 'T') && (line[3] == 'I') && (line[4] == 'O') && (line[5] == 'N') && (line[6] == 'S') && (line[7] == ' ')) { + if ((lineLen >= 9) && (line[1] == 'P') && (line[2] == 'T') && (line[3] == 'I') && (line[4] == 'O') && (line[5] == 'N') && (line[6] == 'S') && (line[7] == ' ')) { urlBegin = 8; method = Http::OPTIONS; } break; case 'C': - if ((line[1] == 'O') && (line[2] == 'N') && (line[3] == 'N') && (line[4] == 'E') && (line[5] == 'C') && (line[6] == 'T') && (line[7] == ' ')) { + if ((lineLen >= 9) && (line[1] == 'O') && (line[2] == 'N') && (line[3] == 'N') && (line[4] == 'E') && (line[5] == 'C') && (line[6] == 'T') && (line[7] == ' ')) { urlBegin = 8; method = Http::CONNECT; } break; case 'B': - if ((line[1] == 'R') && (line[2] == 'E') && (line[3] == 'W') && (line[4] == ' ')) { + if ((lineLen >= 6) && (line[1] == 'R') && (line[2] == 'E') && (line[3] == 'W') && (line[4] == ' ')) { urlBegin = 5; method = Http::BREW; } break; case 'W': - if ((line[1] == 'H') && (line[2] == 'E') && (line[3] == 'N') && (line[4] == ' ')) { + if ((lineLen >= 6) && (line[1] == 'H') && (line[2] == 'E') && (line[3] == 'N') && (line[4] == ' ')) { urlBegin = 5; method = Http::WHEN; } @@ -355,7 +356,8 @@ bool Balau::HttpWorker::handleClient() { return false; } - int urlEnd = line.strrchr(' ') - 1; + // we checked for a space before, so this can't return -1 + size_t urlEnd = line.strrchr(' ') - 1; if (urlEnd < urlBegin) { Printer::elog(E_HTTPSERVER, "%s has a misformated URI (or no space after it)", m_name.to_charp()); @@ -365,9 +367,9 @@ bool Balau::HttpWorker::handleClient() { uri = line.extract(urlBegin, urlEnd - urlBegin + 1); - int httpBegin = urlEnd + 2; + size_t httpBegin = urlEnd + 2; - if ((httpBegin + 5) >= line.strlen()) { + if ((httpBegin + 5) >= lineLen) { Printer::elog(E_HTTPSERVER, "%s doesn't have enough characters after the URI", m_name.to_charp()); send400(); return false; @@ -392,7 +394,7 @@ bool Balau::HttpWorker::handleClient() { } } else { // parse HTTP header. - int colon = line.strchr(':'); + ssize_t colon = line.strchr(':'); if (colon <= 0) { Printer::elog(E_HTTPSERVER, "%s has an invalid HTTP header", m_name.to_charp()); send400(); @@ -405,7 +407,7 @@ bool Balau::HttpWorker::handleClient() { if (key == "Cookie") { String::List cookiesStrs = value.split(';'); for (auto & value: cookiesStrs) { - int equal = value.strchr('='); + ssize_t equal = value.strchr('='); if (equal > 0) { key = value.extract(0, equal).trim(); value = value.extract(equal + 1).trim(); @@ -533,7 +535,7 @@ bool Balau::HttpWorker::handleClient() { } } - int variablesPos = uri.strchr('?'); + ssize_t variablesPos = uri.strchr('?'); if (variablesPos >= 0) { char * variablesStr = uri.strdup(variablesPos + 1); @@ -545,7 +547,7 @@ bool Balau::HttpWorker::handleClient() { } if (uri.extract(0, 7) == "http://") { - int hostEnd = uri.strchr('/', 7); + ssize_t hostEnd = uri.strchr('/', 7); if (hostEnd < 0) { host = uri.extract(7); diff --git a/src/Input.cc b/src/Input.cc index d266650..c76a595 100644 --- a/src/Input.cc +++ b/src/Input.cc @@ -113,7 +113,7 @@ void Balau::Input::open() throw (GeneralException) { throw GeneralException(String("Unable to open file ") + m_name + " for reading: " + strerror_r(cbResults->errorno, str, sizeof(str)) + " (err#" + cbResults->errorno + ")"); } } else { - m_fd = cbResults->result; + m_fd = (int) cbResults->result; } delete cbResults; diff --git a/src/LuaBigInt.cc b/src/LuaBigInt.cc index b608afd..c02ef11 100644 --- a/src/LuaBigInt.cc +++ b/src/LuaBigInt.cc @@ -139,7 +139,7 @@ int sLua_BigInt::BigInt_proceed_static(Lua & L, int n, int caller) { a = new BigInt(); s = L.tostring(1); if (n == 2) - radix = L.tonumber(-1); + radix = (int) L.tonumber(-1); a->set(s, radix); } else if (n == 1) { if (L.istable()) { @@ -178,7 +178,7 @@ int sLua_BigInt::BigInt_proceed(Lua & L, int n, BigInt * a, int caller) { if (L.type() == LUA_TSTRING) { s = L.tostring(2); if (n == 3) - radix = L.tonumber(-1); + radix = (int) L.tonumber(-1); a->set(s, radix); } else { lua_Number f = L.tonumber(); @@ -187,11 +187,11 @@ int sLua_BigInt::BigInt_proceed(Lua & L, int n, BigInt * a, int caller) { r = 0; break; case BIGINT_SET2EXPT: - a->set2expt(L.tonumber()); + a->set2expt((int) L.tonumber()); break; case BIGINT_TOSTRING: if (n == 3) - radix = L.tonumber(-1); + radix = (int) L.tonumber(-1); L.push(a->toString(radix)); r = 1; break; @@ -245,7 +245,7 @@ int sLua_BigInt::BigInt_proceed(Lua & L, int n, BigInt * a, int caller) { LuaBigIntFactory cf(c = new BigInt()); cf.pushDestruct(L); } - *c = *a << L.tonumber(); + *c = *a << (unsigned int) L.tonumber(); r = 1; break; case BIGINT_SHR: @@ -253,7 +253,7 @@ int sLua_BigInt::BigInt_proceed(Lua & L, int n, BigInt * a, int caller) { LuaBigIntFactory cf(c = new BigInt()); cf.pushDestruct(L); } - *c = *a >> L.tonumber(); + *c = *a >> (unsigned int) L.tonumber(); r = 1; break; case BIGINT_DO_ADD: @@ -277,10 +277,10 @@ int sLua_BigInt::BigInt_proceed(Lua & L, int n, BigInt * a, int caller) { *a %= *b; break; case BIGINT_DO_SHL: - *a <<= L.tonumber(); + *a <<= (unsigned int) L.tonumber(); break; case BIGINT_DO_SHR: - *a >>= L.tonumber(); + *a >>= (unsigned int) L.tonumber(); break; case BIGINT_UNM: { diff --git a/src/LuaHandle.cc b/src/LuaHandle.cc index 67a1496..168d43a 100644 --- a/src/LuaHandle.cc +++ b/src/LuaHandle.cc @@ -120,19 +120,19 @@ int sLua_IOHandle::IOHandle_proceed(Balau::Lua & L, int n, IOHandle * obj, int c break; case IOHANDLE_WRITEU8: { - Balau::Future c = h->writeU8(L.tonumber()); + Balau::Future c = h->writeU8((uint8_t) L.tonumber()); return L.yield(Balau::Future([L, c]() mutable { c.run(); return 0; })); } break; case IOHANDLE_WRITEU16: { - Balau::Future c = h->writeU16(L.tonumber()); + Balau::Future c = h->writeU16((uint16_t) L.tonumber()); return L.yield(Balau::Future([L, c]() mutable { c.run(); return 0; })); } break; case IOHANDLE_WRITEU32: { - Balau::Future c = h->writeU32(L.tonumber()); + Balau::Future c = h->writeU32((uint32_t) L.tonumber()); return L.yield(Balau::Future([L, c]() mutable { c.run(); return 0; })); } break; @@ -146,7 +146,7 @@ int sLua_IOHandle::IOHandle_proceed(Balau::Lua & L, int n, IOHandle * obj, int c Balau::BigInt b(L.tostring()); v = b.to_uint64(); } else { - v = L.tonumber(); + v = (uint64_t) L.tonumber(); } Balau::Future c = h->writeU64(v); return L.yield(Balau::Future([L, c]() mutable { c.run(); return 0; })); @@ -154,19 +154,19 @@ int sLua_IOHandle::IOHandle_proceed(Balau::Lua & L, int n, IOHandle * obj, int c break; case IOHANDLE_WRITEI8: { - Balau::Future c = h->writeI8(L.tonumber()); + Balau::Future c = h->writeI8((int8_t) L.tonumber()); return L.yield(Balau::Future([L, c]() mutable { c.run(); return 0; })); } break; case IOHANDLE_WRITEI16: { - Balau::Future c = h->writeI16(L.tonumber()); + Balau::Future c = h->writeI16((int16_t) L.tonumber()); return L.yield(Balau::Future([L, c]() mutable { c.run(); return 0; })); } break; case IOHANDLE_WRITEI32: { - Balau::Future c = h->writeI32(L.tonumber()); + Balau::Future c = h->writeI32((int32_t) L.tonumber()); return L.yield(Balau::Future([L, c]() mutable { c.run(); return 0; })); } break; @@ -180,7 +180,7 @@ int sLua_IOHandle::IOHandle_proceed(Balau::Lua & L, int n, IOHandle * obj, int c Balau::BigInt b(L.tostring()); v = b.to_int64(); } else { - v = L.tonumber(); + v = (int64_t) L.tonumber(); } Balau::Future c = h->writeI64(v); return L.yield(Balau::Future([L, c]() mutable { c.run(); return 0; })); diff --git a/src/Output.cc b/src/Output.cc index b653333..1f3fd2c 100644 --- a/src/Output.cc +++ b/src/Output.cc @@ -114,7 +114,7 @@ void Balau::Output::open(bool truncate) throw (GeneralException) { throw GeneralException(String("Unable to open file ") + m_name + " for reading: " + strerror_r(cbResults->errorno, str, sizeof(str)) + " (err#" + cbResults->errorno + ")"); } } else { - m_fd = cbResults->result; + m_fd = (int) cbResults->result; } delete cbResults; diff --git a/src/Selectable.cc b/src/Selectable.cc index de7d178..0efa637 100644 --- a/src/Selectable.cc +++ b/src/Selectable.cc @@ -96,7 +96,7 @@ ssize_t Balau::Selectable::read(void * buf, size_t count) throw (GeneralExceptio int spins = 0; do { - ssize_t r = recv(getSocket(m_fd), (char *) buf, count, 0); + ssize_t r = recv((int) getSocket(m_fd), (char *) buf, count, 0); if (r >= 0) { m_evtR->resetMaybe(); @@ -137,7 +137,7 @@ ssize_t Balau::Selectable::write(const void * buf, size_t count) throw (GeneralE int spins = 0; do { - ssize_t r = send(getSocket(m_fd), (const char *) buf, count, 0); + ssize_t r = send((int) getSocket(m_fd), (const char *) buf, count, 0); EAssert(r != 0, "send() returned 0 (broken pipe ?)"); -- cgit v1.2.3