summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas "Pixel" Noble <pixel@nobis-crew.org>2014-08-09 19:23:48 -0700
committerNicolas "Pixel" Noble <pixel@nobis-crew.org>2014-08-09 19:23:48 -0700
commitbddaf98342a461f4e02389d4db390098fb423fbf (patch)
tree30e472aa10754b2c93a24a3519387b766e814907
parent032872bf6f7c14b0fdbc9cd75daae56bbeb50af0 (diff)
Fixing even more warnings.
-rw-r--r--includes/BHashes.h15
-rw-r--r--includes/BLua.h8
-rw-r--r--includes/Base64.h2
-rw-r--r--src/BLua.cc16
-rw-r--r--src/BString.cc16
-rw-r--r--src/BWebSocket.cc6
-rw-r--r--src/Base64.cc6
-rw-r--r--src/BigInt.cc14
-rw-r--r--src/Buffer.cc2
-rw-r--r--src/Handle.cc31
-rw-r--r--src/HttpServer.cc46
-rw-r--r--src/Input.cc2
-rw-r--r--src/LuaBigInt.cc16
-rw-r--r--src/LuaHandle.cc16
-rw-r--r--src/Output.cc2
-rw-r--r--src/Selectable.cc4
-rw-r--r--win32/project/c-ares.vcxproj6
17 files changed, 112 insertions, 96 deletions
diff --git a/includes/BHashes.h b/includes/BHashes.h
index c08b48d..3d7be49 100644
--- a/includes/BHashes.h
+++ b/includes/BHashes.h
@@ -3,6 +3,8 @@
#include <Exceptions.h>
#include <tomcrypt.h>
+#undef max
+
namespace Balau {
template<const struct ltc_hash_descriptor * desc>
@@ -13,9 +15,16 @@ class Hash {
int r = desc->init(&m_state);
IAssert(r == CRYPT_OK, "init for %s returned %i", desc->name, r);
}
- void update(const uint8_t * data, const size_t len) {
- int r = desc->process(&m_state, data, len);
- IAssert(r == CRYPT_OK, "process for %s returned %i", desc->name, r);
+ void update(const uint8_t * data, size_t len) {
+ while (len) {
+ unsigned long blockLen = std::numeric_limits<unsigned long>::max();
+ if (blockLen > len)
+ blockLen = (unsigned long) len;
+ int r = desc->process(&m_state, data, blockLen);
+ data += blockLen;
+ len -= blockLen;
+ IAssert(r == CRYPT_OK, "process for %s returned %i", desc->name, r);
+ }
}
unsigned final(void * digest, unsigned outlen) {
AAssert(outlen >= digestSize(), "digest size too small being passed on for %s: %u instead of %u", name(), outlen, digestSize());
diff --git a/includes/BLua.h b/includes/BLua.h
index a8df837..b5c147a 100644
--- a/includes/BLua.h
+++ b/includes/BLua.h
@@ -79,8 +79,8 @@ class LuaObjectFactory {
static void pushMeta(Lua & L, const char (&str)[S], lua_CFunction func, int upvalues = 0) {
pushMeta(L, str, S - 1, func, upvalues);
}
- static void pushMethod(Lua & L, const char * name, int strSize, lua_CFunction func, int upvalues = 0);
- static void pushMeta(Lua & L, const char * name, int strSize, lua_CFunction func, int upvalues = 0);
+ static void pushMethod(Lua & L, const char * name, size_t strSize, lua_CFunction func, int upvalues = 0);
+ static void pushMeta(Lua & L, const char * name, size_t strSize, lua_CFunction func, int upvalues = 0);
static LuaObjectBase * getMeInternal(Lua & L, int idx);
friend class Lua;
private:
@@ -132,7 +132,7 @@ class Lua {
void push(bool b) { checkstack(); lua_pushboolean(L, b); }
template<size_t S>
void push(const char (&str)[S]) { checkstack(); lua_pushlstring(L, str, S - 1); }
- void push(const char * str, int size = -1) { if (size < 0) size = strlen(str); checkstack(); lua_pushlstring(L, str, size); }
+ void push(const char * str, ssize_t size = -1) { if (size < 0) size = strlen(str); checkstack(); lua_pushlstring(L, str, size); }
void push(void * p) { checkstack(); lua_pushlightuserdata(L, p); }
void push(lua_CFunction f, int n = 0) { checkstack(); lua_pushcclosure(L, f, n); }
void pop(int idx = 1) { lua_pop(L, idx); }
@@ -379,7 +379,7 @@ class LuaHelpers : public LuaHelpersBase {
lua_functypes_t * tab;
bool method;
- caller = L.tonumber(L.upvalue(1));
+ caller = (int) L.tonumber(L.upvalue(1));
proceed = (proceed_t) L.touserdata(L.upvalue(2));
proceed_static = (proceed_static_t) L.touserdata(L.upvalue(3));
tab = (lua_functypes_t *) L.touserdata(L.upvalue(4));
diff --git a/includes/Base64.h b/includes/Base64.h
index 8d0b71d..05f9d36 100644
--- a/includes/Base64.h
+++ b/includes/Base64.h
@@ -7,7 +7,7 @@ namespace Balau {
class Base64 {
public:
static String encode(const uint8_t * data, int len);
- static int decode(const String & str_in, uint8_t * data_out, size_t outLen = static_cast<size_t>(-1));
+ static ssize_t decode(const String & str_in, uint8_t * data_out, size_t outLen = static_cast<size_t>(-1));
static const double ratio;
private:
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 <luajit.h>
}
+#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<int>::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<int>::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<Balau::Handle> 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<unsigned long>::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<unsigned long>::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<class T>
Balau::Future<T> genericRead(Balau::IO<Balau::Handle> t) {
- std::shared_ptr<T> b(new T);
- int c = 0;
+ T b;
+ size_t c = 0;
return Balau::Future<T>([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<class T>
Balau::Future<T> genericReadBE(Balau::IO<Balau::Handle> t) {
- std::shared_ptr<T> b(new T);
- int c = 0;
- *b.get() = 0;
+ T b;
+ size_t c = sizeof(T);
return Balau::Future<T>([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<int64_t> Balau::Handle::readBEI64() { return genericReadBE<int64_
template<class T>
Balau::Future<void> genericWrite(Balau::IO<Balau::Handle> t, T val) {
std::shared_ptr<T> b(new T(val));
- int c = 0;
+ size_t c = 0;
return Balau::Future<void>([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<void> c = h->writeU8(L.tonumber());
+ Balau::Future<void> c = h->writeU8((uint8_t) L.tonumber());
return L.yield(Balau::Future<int>([L, c]() mutable { c.run(); return 0; }));
}
break;
case IOHANDLE_WRITEU16:
{
- Balau::Future<void> c = h->writeU16(L.tonumber());
+ Balau::Future<void> c = h->writeU16((uint16_t) L.tonumber());
return L.yield(Balau::Future<int>([L, c]() mutable { c.run(); return 0; }));
}
break;
case IOHANDLE_WRITEU32:
{
- Balau::Future<void> c = h->writeU32(L.tonumber());
+ Balau::Future<void> c = h->writeU32((uint32_t) L.tonumber());
return L.yield(Balau::Future<int>([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<void> c = h->writeU64(v);
return L.yield(Balau::Future<int>([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<void> c = h->writeI8(L.tonumber());
+ Balau::Future<void> c = h->writeI8((int8_t) L.tonumber());
return L.yield(Balau::Future<int>([L, c]() mutable { c.run(); return 0; }));
}
break;
case IOHANDLE_WRITEI16:
{
- Balau::Future<void> c = h->writeI16(L.tonumber());
+ Balau::Future<void> c = h->writeI16((int16_t) L.tonumber());
return L.yield(Balau::Future<int>([L, c]() mutable { c.run(); return 0; }));
}
break;
case IOHANDLE_WRITEI32:
{
- Balau::Future<void> c = h->writeI32(L.tonumber());
+ Balau::Future<void> c = h->writeI32((int32_t) L.tonumber());
return L.yield(Balau::Future<int>([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<void> c = h->writeI64(v);
return L.yield(Balau::Future<int>([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 ?)");
diff --git a/win32/project/c-ares.vcxproj b/win32/project/c-ares.vcxproj
index 2276ca5..3f86297 100644
--- a/win32/project/c-ares.vcxproj
+++ b/win32/project/c-ares.vcxproj
@@ -33,21 +33,21 @@
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
- <CharacterSet>Unicode</CharacterSet>
+ <CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
- <CharacterSet>Unicode</CharacterSet>
+ <CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
- <CharacterSet>Unicode</CharacterSet>
+ <CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">