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. --- includes/BHashes.h | 15 ++++++++++++--- includes/BLua.h | 8 ++++---- includes/Base64.h | 2 +- 3 files changed, 17 insertions(+), 8 deletions(-) (limited to 'includes') 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 #include +#undef max + namespace Balau { template @@ -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::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 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(-1)); + static ssize_t decode(const String & str_in, uint8_t * data_out, size_t outLen = static_cast(-1)); static const double ratio; private: -- cgit v1.2.3