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
This commit is contained in:
Solomon Peachy 2026-05-01 22:42:58 -04:00
parent 8e8206f6d5
commit f886bfc572
8 changed files with 19 additions and 11 deletions

View file

@ -46,7 +46,8 @@ static bool search_for_cuesheet(const char *path, struct cuesheet_file *cue_file
{ {
size_t len; size_t len;
char cuepath[MAX_PATH]; char cuepath[MAX_PATH];
char *dot, *slash, *slash_cuepath; char *dot, *slash_cuepath;
const char *slash;
cue_file->pos = 0; cue_file->pos = 0;
cue_file->size = 0; cue_file->size = 0;
@ -281,7 +282,7 @@ bool parse_cuesheet(struct cuesheet_file *cue_file, struct cuesheet *cue)
} }
s = skip_whitespace(line); s = skip_whitespace(line);
/* RECOGNIZED TAGS *********************** /* RECOGNIZED TAGS ***********************
* eCS_TRACK = 0, eCS_INDEX_01, eCS_TITLE, * eCS_TRACK = 0, eCS_INDEX_01, eCS_TITLE,
* eCS_PERFORMER, eCS_SONGWRITER, eCS_FILE, * 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); cue->tracks[cue->track_count-1].offset = parse_cue_index(s);
#endif #endif
} }
else if (option != eCS_NOTFOUND) else if (option != eCS_NOTFOUND)
{ {
char *dest = NULL; char *dest = NULL;
char *string = get_string(s); char *string = get_string(s);

View file

@ -525,7 +525,7 @@ static void read_config_init(int fd)
static int file_find_extension(const char* file) static int file_find_extension(const char* file)
{ {
char *extension = strrchr(file, '.'); const char *extension = strrchr(file, '.');
if (extension) if (extension)
extension++; extension++;
return find_extension(extension); return find_extension(extension);
@ -704,7 +704,7 @@ int filetype_load_plugin(const char* plugin, const char* file)
{ {
int i; int i;
char plugin_name[MAX_PATH]; char plugin_name[MAX_PATH];
char *s; const char *s;
for (i=1;i<filetype_count;i++) for (i=1;i<filetype_count;i++)
{ {

View file

@ -2676,7 +2676,7 @@ bool skin_data_load(enum screen_type screen, struct wps_data *wps_data,
if (isfile) if (isfile)
{ {
/* get the bitmap dir */ /* get the bitmap dir */
char *dot = strrchr(buf, '.'); const char *dot = strrchr(buf, '.');
strmemccpy(bmpdir, buf, dot - buf + 1); strmemccpy(bmpdir, buf, dot - buf + 1);
} }
else else

View file

@ -315,7 +315,7 @@ static void pl_close_control(struct playlist_info *playlist)
/* Check if the filename suggests M3U or M3U8 format. */ /* Check if the filename suggests M3U or M3U8 format. */
static bool is_m3u8_name(const char* filename) static bool is_m3u8_name(const char* filename)
{ {
char *dot = strrchr(filename, '.'); const char *dot = strrchr(filename, '.');
/* Default to M3U8 unless explicitly told otherwise. */ /* Default to M3U8 unless explicitly told otherwise. */
return (!dot || strcasecmp(dot, ".m3u") != 0); return (!dot || strcasecmp(dot, ".m3u") != 0);

View file

@ -497,7 +497,7 @@ static void format_name(char* dest, const char* src, size_t bufsz)
default: default:
{ {
/* Only display the filename */ /* Only display the filename */
char* p = strrchr(src, '/'); const char* p = strrchr(src, '/');
strlcpy(dest, p+1, bufsz); strlcpy(dest, p+1, bufsz);
/* Remove the extension */ /* Remove the extension */
strrsplt(dest, '.'); strrsplt(dest, '.');

View file

@ -45,6 +45,8 @@
#undef strcmp #undef strcmp
#undef strncmp #undef strncmp
#undef strchr #undef strchr
#undef strstr
#undef strrchr
#undef strtok_r #undef strtok_r
#ifdef __APPLE__ #ifdef __APPLE__
#undef strncpy #undef strncpy

View file

@ -51,6 +51,10 @@ int splash_scroller(int timeout, const char* str);
#define floor lfloor #define floor lfloor
#define pow lpow #define pow lpow
/* Just in case */
#undef memchr
#undef strstr
/* Simple substitutions */ /* Simple substitutions */
#define malloc tlsf_malloc #define malloc tlsf_malloc
#define realloc tlsf_realloc #define realloc tlsf_realloc

View file

@ -38,7 +38,7 @@ int codec_init(void)
/* codec_get_buffer() aligns the resulting point to MEM_ALIGN_SIZE. */ /* codec_get_buffer() aligns the resulting point to MEM_ALIGN_SIZE. */
mem_ptr = 0; mem_ptr = 0;
mallocbuf = (unsigned char *)ci->codec_get_buffer((size_t *)&bufsize); mallocbuf = (unsigned char *)ci->codec_get_buffer((size_t *)&bufsize);
return 0; return 0;
} }
@ -64,9 +64,9 @@ void* codec_malloc(size_t size)
if (mem_ptr + (long)size > bufsize) if (mem_ptr + (long)size > bufsize)
return NULL; return NULL;
x=&mallocbuf[mem_ptr]; x=&mallocbuf[mem_ptr];
/* Keep memory aligned to MEM_ALIGN_SIZE. */ /* Keep memory aligned to MEM_ALIGN_SIZE. */
mem_ptr += MEM_ALIGN_UP(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)); return(ci->memcmp(s1,s2,n));
} }
#undef memchr
void* memchr(const void *s, int c, size_t n) void* memchr(const void *s, int c, size_t n)
{ {
return(ci->memchr(s,c,n)); return(ci->memchr(s,c,n));