Run cppcheck static analyzer against code base. Fixed a few warnings.

This commit is contained in:
harry 2024-02-24 08:46:06 -05:00
parent c324a82526
commit e2ac013cbb
8 changed files with 36 additions and 26 deletions

16
scripts/runCppCheck.sh Executable file
View File

@ -0,0 +1,16 @@
#!/bin/bash
PROJECT_ROOT=$( cd "$(dirname ${BASH_SOURCE[0]})"/.. && pwd )
echo $PROJECT_ROOT;
SRC_DIR=$PROJECT_ROOT/src
cd $SRC_DIR;
cppcheck --version
IGNORE_DIRS=" -i ./attic "
IGNORE_DIRS+="-i ./drivers/sdl "
#IGNORE_DIRS+="-i ./drivers/win "
cppcheck --force $IGNORE_DIRS .

View File

@ -364,14 +364,6 @@ endif()
include_directories( ${CMAKE_SOURCE_DIR}/src )
include_directories( ${CMAKE_SOURCE_DIR}/src/drivers )
if(APPLE)
add_definitions( -DPSS_STYLE=1 )
else(APPLE)
if(UNIX)
add_definitions( -DPSS_STYLE=1 )
endif(UNIX)
endif(APPLE)
set(SRC_CORE
${CMAKE_CURRENT_SOURCE_DIR}/asm.cpp
${CMAKE_CURRENT_SOURCE_DIR}/cart.cpp

View File

@ -168,12 +168,12 @@ int NetPlayServer::sendRomLoadReq( NetPlayClient *client )
filepath = GameInfo->filename;
}
}
printf("Prep ROM Load Request: %s \n", filepath );
if (filepath == nullptr)
{
return -1;
}
printf("Prep ROM Load Request: %s \n", filepath );
FILE *fp = ::fopen( filepath, "r");
if (fp == nullptr)

View File

@ -167,10 +167,10 @@ int32 NeoFilterSound(int32 *in, int32 *out, uint32 inlen, int32 *leftover)
void MakeFilters(int32 rate)
{
const int32 *tabs[6]={C44100NTSC,C44100PAL,C48000NTSC,C48000PAL,C96000NTSC,
C96000PAL};
const int32 *sq2tabs[6]={SQ2C44100NTSC,SQ2C44100PAL,SQ2C48000NTSC,SQ2C48000PAL,
SQ2C96000NTSC,SQ2C96000PAL};
const int32 *tabs[8]={C44100NTSC,C44100PAL,C48000NTSC,C48000PAL,C96000NTSC,
C96000PAL, nullptr, nullptr};
const int32 *sq2tabs[8]={SQ2C44100NTSC,SQ2C44100PAL,SQ2C48000NTSC,SQ2C48000PAL,
SQ2C96000NTSC,SQ2C96000PAL, nullptr, nullptr};
const int32 *tmp;
int32 x;

View File

@ -22,14 +22,7 @@
#include <stdlib.h>
#include "share.h"
typedef struct {
uint32 mzx,mzy,mzb;
int zap_readbit;
int bogo;
int zappo;
uint64 zaphit;
} ZAPPER;
#include "zapper.h"
static ZAPPER ZD;

View File

@ -60,7 +60,7 @@ static uint8 rp2c05004_colortable[] =
};
main()
int main(int argc, char *argv[])
{
int x;
for(x=0;x<64;x++)
@ -71,4 +71,5 @@ main()
palette[rp2c04001_colortable[x]&0x3F].g,
palette[rp2c04001_colortable[x]&0x3F].b);
}
return 0;
}

View File

@ -96,9 +96,6 @@ typedef uint32_t uint32;
#define GINLINE /* Can't declare a function INLINE
and global in MSVC. Bummer.
*/
#define PSS_STYLE 2 /* Does MSVC compile for anything
other than Windows/DOS targets?
*/
#if _MSC_VER >= 1300
#pragma warning(disable:4244) //warning C4244: '=' : conversion from 'uint32' to 'uint8', possible loss of data
@ -110,6 +107,17 @@ typedef uint32_t uint32;
#endif
#endif
#if defined(__linux__) || defined(__APPLE__) || defined(__unix__)
#define PSS_STYLE 1
#elif defined(MSVC)
#define PSS_STYLE 2 /* Does MSVC compile for anything
other than Windows/DOS targets?
*/
#endif
#if PSS_STYLE==2
#define PSS "\\"