Skip to content

Commit

Permalink
Enable warnings when compiling.
Browse files Browse the repository at this point in the history
Fixed remaining warnings.
  • Loading branch information
bkacjios committed Jan 3, 2025
1 parent 5b0c351 commit 54bee63
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 17 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
40 changes: 25 additions & 15 deletions mumble/buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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:
Expand All @@ -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;
}

Expand Down Expand Up @@ -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);
}

Expand Down
2 changes: 2 additions & 0 deletions mumble/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand Down

0 comments on commit 54bee63

Please sign in to comment.