misc: Address issues uncovered with GCC 16 + binutils 2.46 (1/N)

rockbox-gerrit-noreply--- via rockbox-cvs <[email protected]> Fri, 1 May 2026 22:51:22 -0400
Newsgroups gmane.comp.systems.archos.rockbox.cvs
Message-ID <[email protected]>
commit f886bfc572f6a102ed1969be6c0316402a2cbb14
Author: Solomon Peachy <[email protected]>
Date:   Fri May 1 22:42:58 2026 -0400

    misc:  Address issues uncovered with GCC 16 + binutils 2.46 (1/N)
    
     * Funky macro-based definitions for memchr and strstr
       which require an #undef before we use our own in codecs & plugins
     * Return value of of strstr is const
    
    Still have several more warnings and link failure with some plugins
    but this is a good start.
    
    Change-Id: Ife1f2d3e6f0e0629e3125a9058abc39c6102f452

diff --git a/apps/cuesheet.c b/apps/cuesheet.c
index c5a1aacad9..9779f40c5d 100644
--- a/apps/cuesheet.c
+++ b/apps/cuesheet.c
@@ -46,7 +46,8 @@ static bool search_for_cuesheet(const char *path, struct cuesheet_file *cue_file
 {
     size_t len;
     char cuepath[MAX_PATH];
-    char *dot, *slash, *slash_cuepath;
+    char *dot, *slash_cuepath;
+    const char *slash;
 
     cue_file->pos = 0;
     cue_file->size = 0;
@@ -281,7 +282,7 @@ bool parse_cuesheet(struct cuesheet_file *cue_file, struct cuesheet *cue)
         }
         s = skip_whitespace(line);
 
-/*   RECOGNIZED  TAGS *********************** 
+/*   RECOGNIZED  TAGS ***********************
 *    eCS_TRACK = 0, eCS_INDEX_01, eCS_TITLE,
 *    eCS_PERFORMER, eCS_SONGWRITER, eCS_FILE,
 */
@@ -306,7 +307,7 @@ bool parse_cuesheet(struct cuesheet_file *cue_file, struct cuesheet *cue)
             cue->tracks[cue->track_count-1].offset = parse_cue_index(s);
 #endif
         }
-        else if (option != eCS_NOTFOUND) 
+        else if (option != eCS_NOTFOUND)
         {
             char *dest = NULL;
             char *string = get_string(s);
diff --git a/apps/filetypes.c b/apps/filetypes.c
index 88e6a17666..0e16b2c24b 100644
--- a/apps/filetypes.c
+++ b/apps/filetypes.c
@@ -525,7 +525,7 @@ static void read_config_init(int fd)
 
 static int file_find_extension(const char* file)
 {
-    char *extension = strrchr(file, '.');
+    const char *extension = strrchr(file, '.');
     if (extension)
         extension++;
     return find_extension(extension);
@@ -704,7 +704,7 @@ int filetype_load_plugin(const char* plugin, const char* file)
 {
     int i;
     char plugin_name[MAX_PATH];
-    char *s;
+    const char *s;
 
     for (i=1;i<filetype_count;i++)
     {
diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c
index c3294c53bf..1030d3926c 100644
--- a/apps/gui/skin_engine/skin_parser.c
+++ b/apps/gui/skin_engine/skin_parser.c
@@ -2676,7 +2676,7 @@ bool skin_data_load(enum screen_type screen, struct wps_data *wps_data,
     if (isfile)
     {
         /* get the bitmap dir */
-        char *dot = strrchr(buf, '.');
+        const char *dot = strrchr(buf, '.');
         strmemccpy(bmpdir, buf, dot - buf + 1);
     }
     else
diff --git a/apps/playlist.c b/apps/playlist.c
index 056bab957f..c30b323f87 100644
--- a/apps/playlist.c
+++ b/apps/playlist.c
@@ -315,7 +315,7 @@ static void pl_close_control(struct playlist_info *playlist)
 /* Check if the filename suggests M3U or M3U8 format. */
 static bool is_m3u8_name(const char* filename)
 {
-    char *dot = strrchr(filename, '.');
+    const char *dot = strrchr(filename, '.');
 
     /* Default to M3U8 unless explicitly told otherwise. */
     return (!dot || strcasecmp(dot, ".m3u") != 0);
diff --git a/apps/playlist_viewer.c b/apps/playlist_viewer.c
index 392131a8a9..4ec8dd59bf 100644
--- a/apps/playlist_viewer.c
+++ b/apps/playlist_viewer.c
@@ -497,7 +497,7 @@ static void format_name(char* dest, const char* src, size_t bufsz)
         default:
         {
             /* Only display the filename */
-            char* p = strrchr(src, '/');
+            const char* p = strrchr(src, '/');
             strlcpy(dest, p+1, bufsz);
             /* Remove the extension */
             strrsplt(dest, '.');
diff --git a/apps/plugin.h b/apps/plugin.h
index 6abab07cd0..50fe1508ab 100644
--- a/apps/plugin.h
+++ b/apps/plugin.h
@@ -45,6 +45,8 @@
 #undef strcmp
 #undef strncmp
 #undef strchr
+#undef strstr
+#undef strrchr
 #undef strtok_r
 #ifdef __APPLE__
 #undef strncpy
diff --git a/apps/plugins/lua/rockconf.h b/apps/plugins/lua/rockconf.h
index d55b3d434f..15d3f16106 100644
--- a/apps/plugins/lua/rockconf.h
+++ b/apps/plugins/lua/rockconf.h
@@ -51,6 +51,10 @@ int splash_scroller(int timeout, const char* str);
 #define floor   lfloor
 #define pow     lpow
 
+/* Just in case */
+#undef memchr
+#undef strstr
+
 /* Simple substitutions */
 #define malloc   tlsf_malloc
 #define realloc  tlsf_realloc
diff --git a/lib/rbcodec/codecs/lib/codeclib.c b/lib/rbcodec/codecs/lib/codeclib.c
index 6e8c209489..f1400bbd4e 100644
--- a/lib/rbcodec/codecs/lib/codeclib.c
+++ b/lib/rbcodec/codecs/lib/codeclib.c
@@ -38,7 +38,7 @@ int codec_init(void)
     /* codec_get_buffer() aligns the resulting point to MEM_ALIGN_SIZE. */
     mem_ptr = 0;
     mallocbuf = (unsigned char *)ci->codec_get_buffer((size_t *)&bufsize);
-  
+
     return 0;
 }
 
@@ -64,9 +64,9 @@ void* codec_malloc(size_t size)
 
     if (mem_ptr + (long)size > bufsize)
         return NULL;
-    
+
     x=&mallocbuf[mem_ptr];
-    
+
     /* Keep memory aligned to MEM_ALIGN_SIZE. */
     mem_ptr += MEM_ALIGN_UP(size);
 
@@ -136,6 +136,7 @@ int memcmp(const void *s1, const void *s2, size_t n)
     return(ci->memcmp(s1,s2,n));
 }
 
+#undef memchr
 void* memchr(const void *s, int c, size_t n)
 {
     return(ci->memchr(s,c,n));
-- 
rockbox-cvs mailing list
[email protected]
https://lists.haxx.se/mailman/listinfo/rockbox-cvs