Adding Werror to compilation and solve warnings

This commit is contained in:
Francisco Javier Trujillo Mata
2024-05-10 21:54:56 +02:00
parent 4c61f81a14
commit f1ea3f8f9c
8 changed files with 23 additions and 19 deletions

View File

@@ -72,7 +72,7 @@ AC_SUBST(PSPSDK_INCLUDEDIR)
AC_SUBST(PSPSDK_LIBDIR) AC_SUBST(PSPSDK_LIBDIR)
# CFLAGS and CXXFLAGS used to build pspsdk libraries. # CFLAGS and CXXFLAGS used to build pspsdk libraries.
PSPSDK_CFLAGS="$CFLAGS -mno-gpopt -Wall -D_PSP_FW_VERSION=600" PSPSDK_CFLAGS="$CFLAGS -mno-gpopt -Wall -Werror -D_PSP_FW_VERSION=600"
PSPSDK_CXXFLAGS="$PSPSDK_CFLAGS -fno-exceptions -fno-rtti" PSPSDK_CXXFLAGS="$PSPSDK_CFLAGS -fno-exceptions -fno-rtti"
if test "$with_pthread" = no ; then if test "$with_pthread" = no ; then
PSPSDK_CFLAGS="$PSPSDK_CFLAGS -DPSP_WITHOUT_PTHREAD" PSPSDK_CFLAGS="$PSPSDK_CFLAGS -DPSP_WITHOUT_PTHREAD"

View File

@@ -30,13 +30,6 @@ void pspAudioSetVolume(int channel, int left, int right)
AudioStatus[channel].volumeleft = left; AudioStatus[channel].volumeleft = left;
} }
void pspAudioChannelThreadCallback(int channel, void *buf, unsigned int reqn)
{
pspAudioCallback_t callback;
callback=AudioStatus[channel].callback;
}
void pspAudioSetChannelCallback(int channel, pspAudioCallback_t callback, void *pdata) void pspAudioSetChannelCallback(int channel, pspAudioCallback_t callback, void *pdata)
{ {
volatile psp_audio_channelinfo *pci = &AudioStatus[channel]; volatile psp_audio_channelinfo *pci = &AudioStatus[channel];

View File

@@ -41,7 +41,6 @@ void pspAudioEndPre();
void pspAudioEnd(); void pspAudioEnd();
void pspAudioSetVolume(int channel, int left, int right); void pspAudioSetVolume(int channel, int left, int right);
void pspAudioChannelThreadCallback(int channel, void *buf, unsigned int reqn);
void pspAudioSetChannelCallback(int channel, pspAudioCallback_t callback, void *pdata); void pspAudioSetChannelCallback(int channel, pspAudioCallback_t callback, void *pdata);
int pspAudioOutBlocking(unsigned int channel, unsigned int vol1, unsigned int vol2, void *buf); int pspAudioOutBlocking(unsigned int channel, unsigned int vol1, unsigned int vol2, void *buf);

View File

@@ -12,6 +12,7 @@
#include <pspkernel.h> #include <pspkernel.h>
#include <pspdebug.h> #include <pspdebug.h>
#include <string.h> #include <string.h>
#include <stddef.h>
#define CALL 0x0C000000 #define CALL 0x0C000000
#define CALL_MASK 0xFC000000 #define CALL_MASK 0xFC000000
@@ -21,9 +22,13 @@
extern u32 _ftext; extern u32 _ftext;
extern u32 _etext; extern u32 _etext;
/* Ideally should be something which is automatic */ static inline int validAddress(u32 *addr)
#define ELF_START (&_ftext) {
#define ELF_END (&_etext) u32 *elf_start = &_ftext;
u32 *elf_end = &_etext;
ptrdiff_t startDiff = addr - elf_start;
return (startDiff >= 2) && (addr < elf_end);
}
/* This is a blatently wrong way of doing a stack trace, but I felt as long as you use some intelligence you /* This is a blatently wrong way of doing a stack trace, but I felt as long as you use some intelligence you
could easily work out if some calls in the trace were invalid :P */ could easily work out if some calls in the trace were invalid :P */
@@ -32,7 +37,7 @@ static int _pspDebugDoStackTrace(u32 *sp, u32 *sp_end, u32 *ra, PspDebugStackTra
int count = 0; int count = 0;
int recurse = 0; int recurse = 0;
if((ra >= (ELF_START + 2)) && (ra < ELF_END) && (IS_CALL(ra[-2]))) if (validAddress(ra) && (IS_CALL(ra[-2])))
{ {
trace[count].func_addr = CALL_ADDR(ra[-2]); trace[count].func_addr = CALL_ADDR(ra[-2]);
trace[count].call_addr = (u32) (&ra[-2]); trace[count].call_addr = (u32) (&ra[-2]);
@@ -48,7 +53,7 @@ static int _pspDebugDoStackTrace(u32 *sp, u32 *sp_end, u32 *ra, PspDebugStackTra
addr = (u32*) *sp; addr = (u32*) *sp;
/* Check that the address could possibly be a valid ra address */ /* Check that the address could possibly be a valid ra address */
if((addr >= (ELF_START + 2)) && (addr < ELF_END)) if (validAddress(addr))
{ {
if(IS_CALL(addr[-2])) if(IS_CALL(addr[-2]))
{ {

View File

@@ -152,7 +152,8 @@ int _open(const char *buf, int flags, int mode) {
return __set_errno(scefd); return __set_errno(scefd);
} }
} }
#else
int _open(const char *buf, int flags, int mode);
#endif #endif
#ifdef F__close #ifdef F__close
@@ -339,8 +340,6 @@ int lstat(const char *filename, struct stat *buf)
#ifdef F__fstat #ifdef F__fstat
int _fstat(int fd, struct stat *buf) { int _fstat(int fd, struct stat *buf) {
int ret;
SceOff oldpos;
if (!__IS_FD_VALID(fd)) { if (!__IS_FD_VALID(fd)) {
errno = EBADF; errno = EBADF;
return -1; return -1;
@@ -1070,6 +1069,8 @@ int statvfs (const char *__path, struct statvfs *__buf)
__buf->f_bfree = inf.freeClusters; __buf->f_bfree = inf.freeClusters;
__buf->f_bavail = inf.freeClusters; __buf->f_bavail = inf.freeClusters;
__buf->f_namemax = MAXNAMLEN; __buf->f_namemax = MAXNAMLEN;
return 0;
} }
#endif /* F_statvfs */ #endif /* F_statvfs */

View File

@@ -92,7 +92,8 @@ void __libcglue_deinit();
#endif #endif
#ifdef F__exit #ifdef F__exit
void _exit(int status) __attribute__((__noreturn__))
void _exit (int __status)
{ {
__libcglue_deinit(); __libcglue_deinit();
@@ -101,9 +102,12 @@ void _exit(int status)
} else { } else {
sceKernelExitGame(); sceKernelExitGame();
} }
while (1); // Avoid warning
} }
#else #else
void _exit(int status); __attribute__((__noreturn__))
void _exit (int __status);
#endif #endif
#ifdef F_abort #ifdef F_abort

View File

@@ -15,6 +15,7 @@
*/ */
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <sys/lock.h> #include <sys/lock.h>
#include <pspthreadman.h> #include <pspthreadman.h>

View File

@@ -12,6 +12,7 @@
#ifndef PSP_WITHOUT_PTHREAD #ifndef PSP_WITHOUT_PTHREAD
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include <pspkerneltypes.h> #include <pspkerneltypes.h>
#include <pspthreadman.h> #include <pspthreadman.h>