Fix some sanitizer issues, and disable LTO in debug builds to save some iteration time.

This commit is contained in:
Cory McWilliams 2024-08-14 19:40:20 -04:00
parent 463951a4f1
commit 3d58094199
7 changed files with 22 additions and 13 deletions

View File

@ -60,11 +60,10 @@ CFLAGS += \
-ffunction-sections \ -ffunction-sections \
-fdata-sections \ -fdata-sections \
-fno-exceptions \ -fno-exceptions \
-g \ -g
-flto
LDFLAGS += \ LDFLAGS += \
-flto=auto \ -Wno-attributes \
-Wno-attributes -flto=auto
ANDROID_MIN_SDK_VERSION := 24 ANDROID_MIN_SDK_VERSION := 24
ANDROID_TARGET_SDK_VERSION := 34 ANDROID_TARGET_SDK_VERSION := 34
@ -172,7 +171,9 @@ $(ANDROID_TARGETS): CFLAGS += \
-funwind-tables -funwind-tables
$(ANDROID_TARGETS): LDFLAGS += --sysroot $(ANDROID_NDK)/toolchains/llvm/prebuilt/linux-x86_64/sysroot -fPIC $(ANDROID_TARGETS): LDFLAGS += --sysroot $(ANDROID_NDK)/toolchains/llvm/prebuilt/linux-x86_64/sysroot -fPIC
$(DEBUG_TARGETS): CFLAGS += -DDEBUG -Og $(DEBUG_TARGETS): CFLAGS += -DDEBUG -Og
$(RELEASE_TARGETS): CFLAGS += -DNDEBUG $(RELEASE_TARGETS): CFLAGS += \
-DNDEBUG \
-flto
$(NONANDROID_RELEASE_TARGETS): CFLAGS += -O3 $(NONANDROID_RELEASE_TARGETS): CFLAGS += -O3
$(ANDROID_RELEASE_TARGETS): CFLAGS += -Oz $(ANDROID_RELEASE_TARGETS): CFLAGS += -Oz
$(WINDOWS_TARGETS): CC = x86_64-w64-mingw32-gcc-win32 $(WINDOWS_TARGETS): CC = x86_64-w64-mingw32-gcc-win32

View File

@ -1071,7 +1071,7 @@ void* tf_http_get_user_data(tf_http_t* http)
const char* tf_http_get_cookie(const char* cookie_header, const char* name) const char* tf_http_get_cookie(const char* cookie_header, const char* name)
{ {
if (!cookie_header) if (!cookie_header || !name)
{ {
return NULL; return NULL;
} }

View File

@ -3174,8 +3174,9 @@ static void _tf_ssb_on_broadcast_listener_recv(uv_udp_t* handle, ssize_t nread,
tf_free(buf->base); tf_free(buf->base);
} }
void tf_ssb_visit_broadcasts( void tf_ssb_visit_broadcasts(tf_ssb_t* ssb,
tf_ssb_t* ssb, void (*callback)(const char* host, const struct sockaddr_in* addr, tf_ssb_broadcast_origin_t origin, tf_ssb_connection_t* tunnel, const uint8_t* pub, void* user_data), void* user_data) void (*callback)(const char* host, const struct sockaddr_in* addr, tf_ssb_broadcast_origin_t origin, tf_ssb_connection_t* tunnel, const uint8_t* pub, void* user_data),
void* user_data)
{ {
time_t now = time(NULL); time_t now = time(NULL);
tf_ssb_broadcast_t* next = NULL; tf_ssb_broadcast_t* next = NULL;

View File

@ -306,8 +306,9 @@ bool tf_ssb_whoami(tf_ssb_t* ssb, char* out_id, size_t out_id_size);
** @param callback The callback. ** @param callback The callback.
** @param user_data User data for the callback. ** @param user_data User data for the callback.
*/ */
void tf_ssb_visit_broadcasts( void tf_ssb_visit_broadcasts(tf_ssb_t* ssb,
tf_ssb_t* ssb, void (*callback)(const char* host, const struct sockaddr_in* addr, tf_ssb_broadcast_origin_t origin, tf_ssb_connection_t* tunnel, const uint8_t* pub, void* user_data), void* user_data); void (*callback)(const char* host, const struct sockaddr_in* addr, tf_ssb_broadcast_origin_t origin, tf_ssb_connection_t* tunnel, const uint8_t* pub, void* user_data),
void* user_data);
/** /**
** Get the identities of all active connections. ** Get the identities of all active connections.

View File

@ -231,7 +231,11 @@ static void _tf_ssb_import_app_json(tf_ssb_t* ssb, uv_loop_t* loop, JSContext* c
void tf_ssb_import(tf_ssb_t* ssb, const char* user, const char* path) void tf_ssb_import(tf_ssb_t* ssb, const char* user, const char* path)
{ {
if (strlen(path) > strlen(".json") && strcasecmp(path + strlen(path) - strlen(".json"), ".json") == 0) if (!path)
{
return;
}
else if (strlen(path) > strlen(".json") && strcasecmp(path + strlen(path) - strlen(".json"), ".json") == 0)
{ {
_tf_ssb_import_app_json(ssb, tf_ssb_get_loop(ssb), tf_ssb_get_context(ssb), user, path); _tf_ssb_import_app_json(ssb, tf_ssb_get_loop(ssb), tf_ssb_get_context(ssb), user, path);
} }

View File

@ -1450,7 +1450,8 @@ typedef struct _broadcasts_t
int length; int length;
} broadcasts_t; } broadcasts_t;
static void _tf_ssb_broadcasts_visit(const char* host, const struct sockaddr_in* addr, tf_ssb_broadcast_origin_t origin, tf_ssb_connection_t* tunnel, const uint8_t* pub, void* user_data) static void _tf_ssb_broadcasts_visit(
const char* host, const struct sockaddr_in* addr, tf_ssb_broadcast_origin_t origin, tf_ssb_connection_t* tunnel, const uint8_t* pub, void* user_data)
{ {
broadcasts_t* broadcasts = user_data; broadcasts_t* broadcasts = user_data;
JSValue entry = JS_NewObject(broadcasts->context); JSValue entry = JS_NewObject(broadcasts->context);

View File

@ -747,7 +747,8 @@ static void _break_in_a_bit(tf_ssb_t* ssb, tf_ssb_connection_t* connection, cons
uv_timer_start(&data->timer, _close_callback, 3000, 0); uv_timer_start(&data->timer, _close_callback, 3000, 0);
} }
static void _ssb_test_room_broadcasts_visit(const char* host, const struct sockaddr_in* addr, tf_ssb_broadcast_origin_t origin, tf_ssb_connection_t* tunnel, const uint8_t* pub, void* user_data) static void _ssb_test_room_broadcasts_visit(
const char* host, const struct sockaddr_in* addr, tf_ssb_broadcast_origin_t origin, tf_ssb_connection_t* tunnel, const uint8_t* pub, void* user_data)
{ {
tf_ssb_t* ssb = user_data; tf_ssb_t* ssb = user_data;
char id[k_id_base64_len] = { 0 }; char id[k_id_base64_len] = { 0 };