From 54bee6389506fecb770fba9c1eb2daf3dbcbea30 Mon Sep 17 00:00:00 2001 From: Bkacjios Date: Fri, 3 Jan 2025 15:11:03 -0500 Subject: [PATCH] Enable warnings when compiling. Fixed remaining warnings. --- CMakeLists.txt | 2 +- Makefile | 2 +- mumble/buffer.c | 40 +++++++++++++++++++++++++--------------- mumble/util.c | 2 ++ 4 files changed, 29 insertions(+), 17 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4e760f9..629351f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,7 @@ find_package(Threads REQUIRED) pkg_check_modules(PKG_DEPS REQUIRED ${DEPENDENCIES}) # Compiler flags -set(CMAKE_C_FLAGS "-fPIC -I.") +set(CMAKE_C_FLAGS "-fPIC -I. -Wall") if("${LUAVER}" STREQUAL "luajit") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DLUAJIT") endif() diff --git a/Makefile b/Makefile index b864fd5..afa1b44 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ DEPENDENCIES = libssl $(LUAVER) libprotobuf-c opus sndfile libuv LIBRARIES = $(shell pkg-config --libs $(DEPENDENCIES)) INCLUDES = $(shell pkg-config --cflags $(DEPENDENCIES)) -CFLAGS = -fPIC -I. +CFLAGS = -fPIC -I. -Wall ifneq (,$(findstring luajit,$(LUAVER))) CFLAGS += -DLUAJIT diff --git a/mumble/buffer.c b/mumble/buffer.c index f3f3740..213eb2e 100755 --- a/mumble/buffer.c +++ b/mumble/buffer.c @@ -182,6 +182,8 @@ uint8_t buffer_readVarInt(ByteBuffer* buffer, uint64_t* output) { uint8_t size = 0; + uint8_t byte1, byte2, byte3, byte4, byte5, byte6, byte7, byte8; + if ((v & 0x80) == 0x00) { *output = (v & 0x7F); size += 1; @@ -193,22 +195,25 @@ uint8_t buffer_readVarInt(ByteBuffer* buffer, uint64_t* output) { switch (v & 0xFC) { case 0xF0: buffer_available(buffer, 4); - *output = buffer->data[buffer->read_head++] << 24 - | buffer->data[buffer->read_head++] << 16 - | buffer->data[buffer->read_head++] << 8 - | buffer->data[buffer->read_head++]; + byte1 = buffer->data[buffer->read_head++]; + byte2 = buffer->data[buffer->read_head++]; + byte3 = buffer->data[buffer->read_head++]; + byte4 = buffer->data[buffer->read_head++]; + *output = byte1 << 24 | byte2 << 16 | byte3 << 8 | byte4; size += 5; break; case 0xF4: buffer_available(buffer, 8); - *output = (uint64_t)buffer->data[buffer->read_head++] << 56 - | (uint64_t)buffer->data[buffer->read_head++] << 48 - | (uint64_t)buffer->data[buffer->read_head++] << 40 - | (uint64_t)buffer->data[buffer->read_head++] << 32 - | buffer->data[buffer->read_head++] << 24 - | buffer->data[buffer->read_head++] << 16 - | buffer->data[buffer->read_head++] << 8 - | buffer->data[buffer->read_head++]; + byte1 = buffer->data[buffer->read_head++]; + byte2 = buffer->data[buffer->read_head++]; + byte3 = buffer->data[buffer->read_head++]; + byte4 = buffer->data[buffer->read_head++]; + byte5 = buffer->data[buffer->read_head++]; + byte6 = buffer->data[buffer->read_head++]; + byte7 = buffer->data[buffer->read_head++]; + byte8 = buffer->data[buffer->read_head++]; + *output = (uint64_t)byte1 << 56 | (uint64_t)byte2 << 48 | (uint64_t)byte3 << 40 | + (uint64_t)byte4 << 32 | byte5 << 24 | byte6 << 16 | byte7 << 8 | byte8; size += 9; break; case 0xF8: @@ -227,11 +232,16 @@ uint8_t buffer_readVarInt(ByteBuffer* buffer, uint64_t* output) { } } else if ((v & 0xF0) == 0xE0) { buffer_available(buffer, 3); - *output = (v & 0x0F) << 24 | buffer->data[buffer->read_head++] << 16 | buffer->data[buffer->read_head++] << 8 | buffer->data[buffer->read_head++]; + byte1 = buffer->data[buffer->read_head++]; + byte2 = buffer->data[buffer->read_head++]; + byte3 = buffer->data[buffer->read_head++]; + *output = (v & 0x0F) << 24 | byte1 << 16 | byte2 << 8 | byte3; size += 4; } else if ((v & 0xE0) == 0xC0) { buffer_available(buffer, 2); - *output = (v & 0x1F) << 16 | buffer->data[buffer->read_head++] << 8 | buffer->data[buffer->read_head++]; + byte1 = buffer->data[buffer->read_head++]; + byte2 = buffer->data[buffer->read_head++]; + *output = (v & 0x1F) << 16 | byte1 << 8 | byte2; size += 3; } @@ -271,7 +281,7 @@ int mumble_buffer_new(lua_State *l) { break; default: msg = lua_pushfstring(l, "%s or %s expected, got %s", - lua_typename(l, LUA_TNUMBER), lua_typename(l, LUA_TSTRING), luaL_typename(l, 2)); + lua_typename(l, LUA_TNUMBER), lua_typename(l, LUA_TSTRING), luaL_typename(l, 2)); return luaL_argerror(l, 1, msg); } diff --git a/mumble/util.c b/mumble/util.c index 5902542..110f014 100755 --- a/mumble/util.c +++ b/mumble/util.c @@ -25,6 +25,7 @@ void bin_to_strhex(char *bin, size_t binsz, char **result) { } } +/* static void iterate_and_print(lua_State *L, int index) { // Push another reference to the table on top of the stack (so we know // where it is, and this function can work for negative, positive and @@ -51,6 +52,7 @@ static void iterate_and_print(lua_State *L, int index) { lua_pop(L, 1); // Stack is now the same as it was on entry to this function } +*/ void print_unescaped(const char* ptr, int len) { if (!ptr) return;