Skip to content

Commit 3569f03

Browse files
authored
Merge pull request #17 from ps2dev/ee-v4.5.0-gcc15
Fix GCC 15 warnings
2 parents 6462998 + 7e864c9 commit 3569f03

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

newlib/libc/posix/ftw.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,18 @@
2525

2626
#include <ftw.h>
2727

28+
/* Static callback pointer to maintain the ftw callback between calls */
29+
static int (*ftw_callback)(const char *, const struct stat *, int);
30+
31+
static int ftw_wrapper(const char *fpath, const struct stat *sb, int typeflag, struct FTW *ftwbuf)
32+
{
33+
return ftw_callback(fpath, sb, typeflag);
34+
}
35+
2836
int ftw(const char *path, int (*fn)(const char *, const struct stat *, int), int fd_limit)
2937
{
30-
/* The following cast assumes that calling a function with one
31-
* argument more than it needs behaves as expected. This is
32-
* actually undefined, but works on all real-world machines. */
33-
return nftw(path, (int (*)())fn, fd_limit, FTW_PHYS);
38+
ftw_callback = fn;
39+
return nftw(path, ftw_wrapper, fd_limit, FTW_PHYS);
3440
}
3541

3642
#endif /* ! HAVE_OPENDIR */

newlib/libc/posix/glob.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ glob3(pathbuf, pathend, pathend_last, pattern, restpattern, pglob, limit)
620620
* and dirent.h as taking pointers to differently typed opaque
621621
* structures.
622622
*/
623-
struct dirent *(*readdirfunc)();
623+
struct dirent *(*readdirfunc)(void *);
624624

625625
if (pathend > pathend_last)
626626
return (1);
@@ -645,7 +645,7 @@ glob3(pathbuf, pathend, pathend_last, pattern, restpattern, pglob, limit)
645645
if (pglob->gl_flags & GLOB_ALTDIRFUNC)
646646
readdirfunc = pglob->gl_readdir;
647647
else
648-
readdirfunc = readdir;
648+
readdirfunc = (struct dirent *(*)(void *))readdir;
649649
while ((dp = (*readdirfunc)(dirp))) {
650650
u_char *sc;
651651
Char *dc;

0 commit comments

Comments
 (0)