3ds: Various fixes, mostly for compiler warnings

rockbox-gerrit-noreply--- via rockbox-cvs <[email protected]>
Newsgroups gmane.comp.systems.archos.rockbox.cvs
Message-ID <[email protected]>
commit a77c5d2219743d1c4728efdff8a0c4e3d729e7ae
Author: Vencislav Atanasov <[email protected]>
Date:   Thu Mar 12 17:41:13 2026 +0200

    3ds: Various fixes, mostly for compiler warnings
    
    - Move all devkitpro includes before the Rockbox ones so that the macros which are both conflicting and unused can be undef'd
    - Remove unused result variables
    - Exclude an unused function from being compiled for this target
    - Fix hex number formatting
    - Fix the return value of dummy functions
    - Fix macro redefinition in the plugins keypad config
    - Remove duplicate button mapping
    - Turn off -Wchar-subscripts as it's already handled in Rockbox's ctype.h
    
    Change-Id: I3f5a3d492c585f233277a380feaea5fe877a044f

diff --git a/apps/plugins/lib/keymaps.h b/apps/plugins/lib/keymaps.h
index f5194ee053..1570b5a19a 100644
--- a/apps/plugins/lib/keymaps.h
+++ b/apps/plugins/lib/keymaps.h
@@ -310,7 +310,8 @@
       (CONFIG_KEYPAD != ONDAVX777_PAD) && \
       (CONFIG_KEYPAD != CREATIVE_ZENXFI2_PAD) && \
       (CONFIG_KEYPAD != SHANLING_Q1_PAD) && \
-      (CONFIG_KEYPAD != HIBY_R3PROII_PAD)
+      (CONFIG_KEYPAD != HIBY_R3PROII_PAD) && \
+      (CONFIG_KEYPAD != CTRU_PAD)
 #define BTN_FIRE       BUTTON_BOTTOMLEFT
 #define BTN_PAUSE      BUTTON_TOPLEFT
 #endif
diff --git a/apps/plugins/plugin_crt0.c b/apps/plugins/plugin_crt0.c
index 4358f65aa9..0265b1af58 100644
--- a/apps/plugins/plugin_crt0.c
+++ b/apps/plugins/plugin_crt0.c
@@ -28,7 +28,7 @@ PLUGIN_HEADER
 #ifdef CTRU
 /* dummy undefined symbols to build plugins for ctru */
 void __aeabi_unwind_cpp_pr0(void) {}
-struct _reent * _EXFUN(__getreent, (void)) {}
+struct _reent * _EXFUN(__getreent, (void)) { return NULL; }
 #endif
 
 /*
diff --git a/firmware/kernel/thread-common.c b/firmware/kernel/thread-common.c
index 074af1b7e1..326b8ea1cd 100644
--- a/firmware/kernel/thread-common.c
+++ b/firmware/kernel/thread-common.c
@@ -231,7 +231,7 @@ void format_thread_name(char *buf, size_t bufsize,
     snprintf(buf, bufsize, fmt, name, thread->id);
 }
 
-#ifndef HAVE_SDL_THREADS
+#if !defined(HAVE_SDL_THREADS) && !defined(CTRU)
 /*---------------------------------------------------------------------------
  * Returns the maximum percentage of the stack ever used during runtime.
  *---------------------------------------------------------------------------
@@ -252,7 +252,7 @@ static unsigned int stack_usage(uintptr_t *stackptr, size_t stack_size)
 
     return usage;
 }
-#endif /* HAVE_SDL_THREADS */
+#endif /* !defined(HAVE_SDL_THREADS) && !defined(CTRU) */
 
 #if NUM_CORES > 1
 int core_get_debug_info(unsigned int core, struct core_debug_info *infop)
diff --git a/firmware/target/hosted/ctru/backlight-ctru.c b/firmware/target/hosted/ctru/backlight-ctru.c
index 8d45ba0b84..f72ea46d1e 100644
--- a/firmware/target/hosted/ctru/backlight-ctru.c
+++ b/firmware/target/hosted/ctru/backlight-ctru.c
@@ -23,6 +23,10 @@
 #include <unistd.h>
 #include <string.h>
 #include <stdio.h>
+
+#include <3ds/services/gsplcd.h>
+#include <3ds/result.h>
+
 #include "config.h"
 #include "backlight-target.h"
 #include "sysfs.h"
@@ -30,8 +34,6 @@
 #include "lcd.h"
 #include "debug.h"
 
-#include <3ds/services/gsplcd.h>
-#include <3ds/result.h>
 #include "luminance-ctru.h"
 
 /* TODO: To use calibrated values in rockbox,
diff --git a/firmware/target/hosted/ctru/button-ctru.c b/firmware/target/hosted/ctru/button-ctru.c
index c28d7e56ae..59dfffef67 100644
--- a/firmware/target/hosted/ctru/button-ctru.c
+++ b/firmware/target/hosted/ctru/button-ctru.c
@@ -22,6 +22,13 @@
 #include <math.h>
 #include <stdlib.h>         /* EXIT_SUCCESS */
 #include <stdio.h>
+
+#include <3ds/types.h>
+#include <3ds/services/apt.h>
+#include <3ds/services/hid.h>
+#include <3ds/services/mcuhwc.h>
+#include <3ds/services/dsp.h>
+
 #include "config.h"
 #include "button.h"
 #include "kernel.h"
@@ -38,12 +45,6 @@
 
 #include "touchscreen.h"
 
-#include <3ds/types.h>
-#include <3ds/services/apt.h>
-#include <3ds/services/hid.h>
-#include <3ds/services/mcuhwc.h>
-#include <3ds/services/dsp.h>
-
 static u8 old_slider_level = 0;
 static int last_y, last_x;
 
@@ -136,9 +137,6 @@ int button_read_device(int* data)
     if (kDown & KEY_DDOWN) {
         key |= BUTTON_DOWN;
     }
-    if (kDown & KEY_START) {
-        key |= BUTTON_POWER;
-    }
 
     touchPosition touch;
     hidTouchRead(&touch);
diff --git a/firmware/target/hosted/ctru/filesystem-ctru.c b/firmware/target/hosted/ctru/filesystem-ctru.c
index 607a2e2ed6..5643afe8c3 100644
--- a/firmware/target/hosted/ctru/filesystem-ctru.c
+++ b/firmware/target/hosted/ctru/filesystem-ctru.c
@@ -24,6 +24,9 @@
 #include <stdio.h>
 #include <errno.h>
 #include <utime.h>
+
+#include <3ds/archive.h>
+
 #include "config.h"
 #include "system.h"
 #include "file.h"
@@ -33,8 +36,6 @@
 #include "pathfuncs.h"
 #include "string-extra.h"
 
-#include <3ds/archive.h>
-
 void paths_init(void)
 {
     /* is this needed in 3DS? */
diff --git a/firmware/target/hosted/ctru/lc-ctru.c b/firmware/target/hosted/ctru/lc-ctru.c
index 84b0e4534d..286944eed3 100644
--- a/firmware/target/hosted/ctru/lc-ctru.c
+++ b/firmware/target/hosted/ctru/lc-ctru.c
@@ -19,9 +19,15 @@
  *
  ****************************************************************************/
 #define RB_FILESYSTEM_OS
-#include <dlfcn.h>
 #include <stdlib.h>
 #include <string.h>
+
+/* this is part of CTRDL and includes 3ds.h */
+#include <dlfcn.h>
+#ifdef RGB565
+#undef RGB565
+#endif
+
 #include "system.h"
 #include "load_code.h"
 #include "filesystem-ctru.h"
diff --git a/firmware/target/hosted/ctru/lcd-bitmap.c b/firmware/target/hosted/ctru/lcd-bitmap.c
index 571857b9f3..53efbeabca 100644
--- a/firmware/target/hosted/ctru/lcd-bitmap.c
+++ b/firmware/target/hosted/ctru/lcd-bitmap.c
@@ -22,17 +22,22 @@
 #include <math.h>
 #include <stdlib.h>
 #include <string.h>
-#include "debug.h"
-#include "system.h"
-#include "button-ctru.h"
-#include "screendump.h"
-#include "lcd-target.h"
 
 #include <3ds/gfx.h>
+#ifdef RGB565
+#undef RGB565
+#endif
+
 #include <3ds/allocator/linear.h>
 #include <3ds/console.h>
 #include <3ds/services/cfgu.h>
 
+#include "debug.h"
+#include "system.h"
+#include "button-ctru.h"
+#include "screendump.h"
+#include "lcd-target.h"
+
 /*#define LOGF_ENABLE*/
 #include "logf.h"
 
@@ -186,7 +191,7 @@ void lcd_init_device(void)
     /* hidInit(); */
 
     u16 fb_width, fb_height;
-    u8* fb = gfxGetFramebuffer(GFX_BOTTOM, GFX_LEFT, &fb_width, &fb_height);
+    gfxGetFramebuffer(GFX_BOTTOM, GFX_LEFT, &fb_width, &fb_height);
     u32 bufsize = fb_width * fb_height * 2;
 
     dev_fb = (fb_data *) linearAlloc(bufsize);
diff --git a/firmware/target/hosted/ctru/lib/bfile/bfile-internal.h b/firmware/target/hosted/ctru/lib/bfile/bfile-internal.h
index 24618d3fc2..62977a68ad 100644
--- a/firmware/target/hosted/ctru/lib/bfile/bfile-internal.h
+++ b/firmware/target/hosted/ctru/lib/bfile/bfile-internal.h
@@ -10,6 +10,10 @@
 #include <math.h>
 
 #include <3ds/gfx.h>
+#ifdef RGB565
+#undef RGB565
+#endif
+
 #include <3ds/svc.h>
 #include <3ds/types.h>
 #include <3ds/thread.h>
diff --git a/firmware/target/hosted/ctru/lib/sys_dir.c b/firmware/target/hosted/ctru/lib/sys_dir.c
index b997178900..f657d6c15e 100644
--- a/firmware/target/hosted/ctru/lib/sys_dir.c
+++ b/firmware/target/hosted/ctru/lib/sys_dir.c
@@ -19,19 +19,22 @@
  *
  ****************************************************************************/
 #define DIRFUNCTIONS_DEFINED
-#include "config.h"
 #include <errno.h>
 #include <string.h>
+#include "fs_defines.h"
+
+#include <3ds/archive.h>
+#include <3ds/util/utf.h>
+/* this includes a couple of 3ds headers */
+#include "sys_file.h"
+
+#include "config.h"
 #include "debug.h"
 #include "dir.h"
 #include "pathfuncs.h"
 #include "timefuncs.h"
 #include "system.h"
-#include "fs_defines.h"
-#include "sys_file.h"
 
-#include <3ds/archive.h>
-#include <3ds/util/utf.h>
 
 /* This file is based on firmware/common/dir.c */
 
diff --git a/firmware/target/hosted/ctru/lib/sys_file.c b/firmware/target/hosted/ctru/lib/sys_file.c
index 4370627362..6a40cd659f 100644
--- a/firmware/target/hosted/ctru/lib/sys_file.c
+++ b/firmware/target/hosted/ctru/lib/sys_file.c
@@ -18,19 +18,22 @@
  * KIND, either express or implied.
  *
  ****************************************************************************/
-#define RB_FILESYSTEM_OS
-#include "config.h"
-#include "system.h"
 #include <string.h>
 #include <errno.h>
 #include <fcntl.h>
 #include <unistd.h>
 #include <utime.h>
+#include "fs_defines.h"
+
+/* this includes a couple of 3ds headers */
+#include "sys_file.h"
+
+#define RB_FILESYSTEM_OS
+#include "config.h"
+#include "system.h"
 #include "file.h"
 #include "debug.h"
 #include "string-extra.h"
-#include "fs_defines.h"
-#include "sys_file.h"
 
 /* This file is based on firmware/common/file.c */
 
diff --git a/firmware/target/hosted/ctru/lib/sys_thread.h b/firmware/target/hosted/ctru/lib/sys_thread.h
index c951668993..a11a1b3bb4 100644
--- a/firmware/target/hosted/ctru/lib/sys_thread.h
+++ b/firmware/target/hosted/ctru/lib/sys_thread.h
@@ -22,12 +22,12 @@
 #ifndef __SYSTHREAD_H__
 #define __SYSTHREAD_H__
 
-#include "thread.h"
-
 #include <3ds/synchronization.h>
 #include <3ds/thread.h>
 #include <3ds/services/apt.h>
 
+#include "thread.h"
+
 /* Complementary atomic operations */
 bool _AtomicCAS(u32 *ptr, int oldval, int newval);
 #define AtomicGet(ptr) __atomic_load_n((u32*)(ptr), __ATOMIC_SEQ_CST)
diff --git a/firmware/target/hosted/ctru/lib/sys_timer.c b/firmware/target/hosted/ctru/lib/sys_timer.c
index a38d7ca032..60123e6025 100644
--- a/firmware/target/hosted/ctru/lib/sys_timer.c
+++ b/firmware/target/hosted/ctru/lib/sys_timer.c
@@ -24,13 +24,15 @@
 #include <stdio.h>
 #include <string.h>
 #include <assert.h>
-#include "debug.h"
-#include "logf.h"
 
 #include <3ds/os.h>
+/* these include a couple of 3ds headers */
 #include "sys_thread.h"
 #include "sys_timer.h"
 
+#include "debug.h"
+#include "logf.h"
+
 #define CACHELINE_SIZE   128
 
 static bool ticks_started = false;
@@ -283,7 +285,7 @@ void sys_timer_quit(void)
         /* Shutdown the timer thread */
         if (data->thread) {
             LightSemaphore_Release(&data->sem, 1);
-            Result res = threadJoin(data->thread, U64_MAX);
+            threadJoin(data->thread, U64_MAX);
             threadFree(data->thread);
             data->thread = NULL;
         }
diff --git a/firmware/target/hosted/ctru/pcm-ctru.c b/firmware/target/hosted/ctru/pcm-ctru.c
index da941ecc31..048809fa93 100644
--- a/firmware/target/hosted/ctru/pcm-ctru.c
+++ b/firmware/target/hosted/ctru/pcm-ctru.c
@@ -27,6 +27,13 @@
 #include <stdlib.h>
 #include <stdbool.h>
 #include <stdio.h>
+
+#include <3ds/ndsp/ndsp.h>
+#include <3ds/ndsp/channel.h>
+#include <3ds/services/dsp.h>
+#include <3ds/synchronization.h>
+#include <3ds/allocator/linear.h>
+
 #include "config.h"
 #include "debug.h"
 #include "sound.h"
@@ -47,12 +54,6 @@
 #include "pcm_mixer.h"
 #include "pcm_sink.h"
 
-#include <3ds/ndsp/ndsp.h>
-#include <3ds/ndsp/channel.h>
-#include <3ds/services/dsp.h>
-#include <3ds/synchronization.h>
-#include <3ds/allocator/linear.h>
-
 /*#define LOGF_ENABLE*/
 #include "logf.h"
 
diff --git a/firmware/target/hosted/ctru/powermgmt-ctru.c b/firmware/target/hosted/ctru/powermgmt-ctru.c
index 063abf7a7b..85db163e4c 100644
--- a/firmware/target/hosted/ctru/powermgmt-ctru.c
+++ b/firmware/target/hosted/ctru/powermgmt-ctru.c
@@ -22,6 +22,11 @@
 #include <unistd.h>
 #include <stdbool.h>
 
+#include <3ds/types.h>
+#include <3ds/result.h>
+#include <3ds/services/mcuhwc.h>
+#include <3ds/services/ptmu.h>
+
 #include "config.h"
 #include "kernel.h"
 #include "powermgmt.h"
@@ -30,11 +35,6 @@
 #include "system.h"
 #include "debug.h"
 
-#include <3ds/types.h>
-#include <3ds/result.h>
-#include <3ds/services/mcuhwc.h>
-#include <3ds/services/ptmu.h>
-
 void mcuhwc_init(void)
 {
     Result result = mcuHwcInit();
diff --git a/firmware/target/hosted/ctru/system-ctru.c b/firmware/target/hosted/ctru/system-ctru.c
index a091e889c6..777e15bbe8 100644
--- a/firmware/target/hosted/ctru/system-ctru.c
+++ b/firmware/target/hosted/ctru/system-ctru.c
@@ -23,6 +23,14 @@
 #include <stdio.h>
 #include <string.h>
 #include <inttypes.h>
+
+/* this includes a couple of 3ds headers */
+#include "bfile.h"
+
+#include <3ds/types.h>
+#include <3ds/allocator/linear.h>
+#include <3ds/services/cfgu.h>
+
 #include "system.h"
 #include "kernel.h"
 #include "thread-ctru.h"
@@ -32,11 +40,6 @@
 #include "panic.h"
 #include "debug.h"
 
-#include <3ds/types.h>
-#include <3ds/allocator/linear.h>
-#include <3ds/services/cfgu.h>
-#include "bfile.h"
-
 const char      *audiodev = NULL;
 
 #ifdef DEBUG
@@ -94,7 +97,7 @@ void system_init(void)
     
     svcGetThreadPriority(&main_thread_priority, CUR_THREAD_HANDLE);
     if (main_thread_priority != 0x30) {
-        DEBUGF("warning, main_thread_priority = 0x%x\n", main_thread_priority);
+        DEBUGF("warning, main_thread_priority = 0x%lx\n", main_thread_priority);
     }
     
     /* check for New 3DS model */
diff --git a/firmware/target/hosted/ctru/system-ctru.h b/firmware/target/hosted/ctru/system-ctru.h
index 23c63a3c0c..53a01e0b5f 100644
--- a/firmware/target/hosted/ctru/system-ctru.h
+++ b/firmware/target/hosted/ctru/system-ctru.h
@@ -23,12 +23,16 @@
 
 #include <stdbool.h>
 #include <stdbool.h>
-#include "config.h"
-#include "gcc_extensions.h"
 
 #include <3ds/types.h>
 #include <3ds/svc.h>
 #include "sys_timer.h"
+#ifdef BIT
+#undef BIT
+#endif
+
+#include "config.h"
+#include "gcc_extensions.h"
 
 #define HIGHEST_IRQ_LEVEL 1
 
diff --git a/lib/rbcodec/codecs/codec_crt0.c b/lib/rbcodec/codecs/codec_crt0.c
index 4a4dd8ee82..e95b3e31e6 100644
--- a/lib/rbcodec/codecs/codec_crt0.c
+++ b/lib/rbcodec/codecs/codec_crt0.c
@@ -34,7 +34,7 @@ int _start(void) {return 0;}
 #ifdef CTRU
 /* dummy undefined symbols */
 void __aeabi_unwind_cpp_pr0(void) {}
-struct _reent * _EXFUN(__getreent, (void)) {}
+struct _reent * _EXFUN(__getreent, (void)) { return NULL; }
 #endif
 
 enum codec_status codec_start(enum codec_entry_call_reason reason)
diff --git a/tools/configure b/tools/configure
index cf15942b35..f67058e44f 100755
--- a/tools/configure
+++ b/tools/configure
@@ -939,7 +939,7 @@ devkitarmcc () {
         GCCOPTS=`echo $GCCOPTS | sed -e s/\ -Os/\ -Og/`
     fi
 
-    GCCOPTS="$GCCOPTS -fno-builtin -g -Wno-unused-result"
+    GCCOPTS="$GCCOPTS -fno-builtin -g -Wno-unused-result -Wno-char-subscripts"
     GCCOPTS="$GCCOPTS -I$DEVKITPRO/libctru/include -I$DEVKITPRO/portlibs/3ds/include"
     GCCOPTS="$GCCOPTS -mword-relocations -ffunction-sections -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft"
     GCCOPTS="$GCCOPTS -D_GNU_SOURCE=1 -D_REENTRANT -masm-syntax-unified"
-- 
rockbox-cvs mailing list
[email protected]
https://lists.haxx.se/mailman/listinfo/rockbox-cvs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.