Skip to content

Commit

Permalink
Run cppcheck static analyzer against code base. Fixed a few warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
thor2016 committed Feb 24, 2024
1 parent c324a82 commit e2ac013
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 26 deletions.
16 changes: 16 additions & 0 deletions scripts/runCppCheck.sh
Original file line number Diff line number Diff line change
@@ -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 .
8 changes: 0 additions & 8 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/drivers/Qt/NetPlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions src/filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 1 addition & 8 deletions src/input/shadow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/input/zapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ struct ZAPPER
uint8 bogo;
int zappo;
uint64 zaphit;
uint32 lastInput;
uint32 lastInput;
};

#endif
3 changes: 2 additions & 1 deletion src/palettes/conv.c → src/palettes/conv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ static uint8 rp2c05004_colortable[] =
};


main()
int main(int argc, char *argv[])
{
int x;
for(x=0;x<64;x++)
Expand All @@ -71,4 +71,5 @@ main()
palette[rp2c04001_colortable[x]&0x3F].g,
palette[rp2c04001_colortable[x]&0x3F].b);
}
return 0;
}
14 changes: 11 additions & 3 deletions src/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 "\\"
Expand Down

0 comments on commit e2ac013

Please sign in to comment.