From 6f958ddf533753ce7aec12edf3b53a8025a4aabd Mon Sep 17 00:00:00 2001
From: Rudi Heitbaum <rudi@heitbaum.com>
Date: Sat, 4 May 2024 10:03:44 +0000
Subject: [PATCH] fix gcc-14 errors and warnings

---
 lib/lazyusf/audiolib.c |  6 +++---
 lib/lazyusf/cpu_hle.c  |  2 +-
 lib/lazyusf/main.c     | 16 ++++++++--------
 lib/lazyusf/memory.c   |  8 ++++----
 src/USFCodec.cpp       |  2 +-
 5 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/lib/lazyusf/audiolib.c b/lib/lazyusf/audiolib.c
index c567928..f94fef0 100644
--- a/lib/lazyusf/audiolib.c
+++ b/lib/lazyusf/audiolib.c
@@ -53,9 +53,9 @@ int alUnLink(usf_state_t * state, int paddr) {
 //	_asm int 3
 
 	if (element->next)
-        elementNext->prev = element->prev;
-    if (element->prev)
-        elementPrev->next = element->next;
+        	elementNext->prev = element->prev;
+	if (element->prev)
+        	elementPrev->next = element->next;
 	return 1;
 }
 
diff --git a/lib/lazyusf/cpu_hle.c b/lib/lazyusf/cpu_hle.c
index 6b04ced..a6e1ca7 100644
--- a/lib/lazyusf/cpu_hle.c
+++ b/lib/lazyusf/cpu_hle.c
@@ -55,7 +55,7 @@ _HLE_Entry entrys[] = {
 
 //char foundlist[2048];
 
-int sort_entrys(void * a, void * b)
+int sort_entrys(const void * a, const void * b)
 {
 	_HLE_Entry * _a = (_HLE_Entry *)a;
 	_HLE_Entry * _b = (_HLE_Entry *)b;
diff --git a/lib/lazyusf/main.c b/lib/lazyusf/main.c
index bcc55f3..554e1fc 100644
--- a/lib/lazyusf/main.c
+++ b/lib/lazyusf/main.c
@@ -20,18 +20,18 @@ void StopEmulation(usf_state_t * state)
 
 void DisplayError (usf_state_t * state, char * Message, ...) {
 	va_list ap;
-    
-    size_t len = strlen( state->error_message );
-    
-    if ( len )
-        state->error_message[ len++ ] = '\n';
+
+	size_t len = strlen( state->error_message );
+
+	if ( len )
+		state->error_message[ len++ ] = '\n';
 
 	va_start( ap, Message );
 	vsprintf( state->error_message + len, Message, ap );
 	va_end( ap );
-    
-    state->last_error = state->error_message;
-    StopEmulation( state );
+
+	state->last_error = state->error_message;
+	StopEmulation( state );
 
 	//printf("Error: %s\n", Msg);
 }
diff --git a/lib/lazyusf/memory.c b/lib/lazyusf/memory.c
index 444e501..3bd4ab6 100644
--- a/lib/lazyusf/memory.c
+++ b/lib/lazyusf/memory.c
@@ -445,8 +445,8 @@ uint32_t r4300i_SB_VAddr ( usf_state_t * state, uint32_t VAddr, uint8_t Value )
 	address = state->TLB_Map[VAddr >> 12];
 
 	if (address == 0) { return 0; }
-    if (address + (VAddr ^ 3) - (uintptr_t)state->N64MEM < state->RdramSize)
-        *(uint8_t *)(address + (VAddr ^ 3)) = Value;
+	if (address + (VAddr ^ 3) - (uintptr_t)state->N64MEM < state->RdramSize)
+        	*(uint8_t *)(address + (VAddr ^ 3)) = Value;
 
 	return 1;
 }
@@ -489,8 +489,8 @@ uint32_t r4300i_SH_VAddr ( usf_state_t * state, uint32_t VAddr, uint16_t Value )
 	address = state->TLB_Map[VAddr >> 12];
 
 	if (address == 0) { return 0; }
-    if (address + 1 + (VAddr ^ 2) - (uintptr_t)state->N64MEM < state->RdramSize)
-        *(uint16_t *)(address + (VAddr ^ 2)) = Value;
+	if (address + 1 + (VAddr ^ 2) - (uintptr_t)state->N64MEM < state->RdramSize)
+        	*(uint16_t *)(address + (VAddr ^ 2)) = Value;
 	return 1;
 }
 
diff --git a/src/USFCodec.cpp b/src/USFCodec.cpp
index 703e22c..7a439d0 100644
--- a/src/USFCodec.cpp
+++ b/src/USFCodec.cpp
@@ -298,7 +298,7 @@ bool CUSFCodec::CheckEndReached(uint8_t* buffer, int size)
 
   if (buffer && buffer[0] == 0)
   {
-    for (unsigned int i = 0; i < size; i++)
+    for (int i = 0; i < size; i++)
     {
       if (buffer[i] != 0)
       {
