mirror of https://github.com/PCSX2/pcsx2.git
Merge pull request #814 from PCSX2/coverity-qa-high
Fix a bunches of coverity warning/errors.
This commit is contained in:
commit
b60dd9d1fe
15
build.sh
15
build.sh
|
@ -22,6 +22,7 @@ cleanBuild=0
|
|||
useClang=0
|
||||
# 0 => no, 1 => yes, 2 => force yes
|
||||
useCross=2
|
||||
CoverityBuild=0
|
||||
|
||||
for ARG in "$@"; do
|
||||
case "$ARG" in
|
||||
|
@ -41,6 +42,7 @@ for ARG in "$@"; do
|
|||
--no-simd ) flags+=(-DDISABLE_ADVANCE_SIMD=TRUE) ;;
|
||||
--cross-multilib ) flags+=(-DCMAKE_TOOLCHAIN_FILE=cmake/linux-compiler-i386-multilib.cmake); useCross=1; ;;
|
||||
--no-cross-multilib ) useCross=0; ;;
|
||||
--coverity ) CoverityBuild=1; cleanBuild=1; ;;
|
||||
-D* ) flags+=($ARG) ;;
|
||||
|
||||
*)
|
||||
|
@ -66,6 +68,7 @@ for ARG in "$@"; do
|
|||
echo "--no-cross-multilib: Build a native PCSX2"
|
||||
echo "--clang : Build with Clang/llvm"
|
||||
echo "--asan : Enable Address sanitizer"
|
||||
echo "--coverity : Do a build for coverity (require the tool)"
|
||||
|
||||
exit 1
|
||||
esac
|
||||
|
@ -74,6 +77,8 @@ done
|
|||
root=$PWD/$(dirname "$0")
|
||||
log=$root/install_log.txt
|
||||
build=$root/build
|
||||
coverity_dir=cov-int
|
||||
coverity_result=pcsx2-coverity.xz
|
||||
|
||||
if [[ "$cleanBuild" -eq 1 ]]; then
|
||||
echo "Doing a clean build."
|
||||
|
@ -116,7 +121,13 @@ else
|
|||
ncpu=$(grep -w -c processor /proc/cpuinfo)
|
||||
fi
|
||||
|
||||
make -j"$ncpu" 2>&1 | tee -a $log
|
||||
make install 2>&1 | tee -a $log
|
||||
if [[ "$CoverityBuild" -eq 1 ]]; then
|
||||
cov-build --dir $coverity_dir make -j"$ncpu" 2>&1 | tee -a $log
|
||||
# Warning: $coverity_dir must be the root directory
|
||||
(cd $build; tar caf $coverity_result $coverity_dir)
|
||||
else
|
||||
make -j"$ncpu" 2>&1 | tee -a $log
|
||||
make install 2>&1 | tee -a $log
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
|
|
@ -182,7 +182,7 @@ void x86capabilities::CountCores()
|
|||
static const char* tbl_x86vendors[] =
|
||||
{
|
||||
"GenuineIntel",
|
||||
"AuthenticAMD"
|
||||
"AuthenticAMD",
|
||||
"Unknown ",
|
||||
};
|
||||
|
||||
|
|
|
@ -1767,7 +1767,7 @@ static void cdvdWrite16(u8 rt) // SCOMMAND
|
|||
|
||||
cdvdGetMechaVer(&cdvd.Result[1]);
|
||||
cdvdReadRegionParams(&cdvd.Result[3]);//size==8
|
||||
DevCon.WriteLn("REGION PARAMS = %s %s", mg_zones[cdvd.Result[1]], &cdvd.Result[3]);
|
||||
DevCon.WriteLn("REGION PARAMS = %s %s", mg_zones[cdvd.Result[1] & 7], &cdvd.Result[3]);
|
||||
cdvd.Result[1] = 1 << cdvd.Result[1]; //encryption zone; see offset 0x1C in encrypted headers
|
||||
//////////////////////////////////////////
|
||||
cdvd.Result[2] = 0; //??
|
||||
|
|
|
@ -244,7 +244,7 @@ int CsoFileReader::ReadFromFrame(u8 *dest, u64 pos, int maxBytes) {
|
|||
|
||||
// Calculate where the compressed payload is (if compressed.)
|
||||
const u64 frameRawPos = (u64)index0 << m_indexShift;
|
||||
const u64 frameRawSize = (index1 - index0) << m_indexShift;
|
||||
const u64 frameRawSize = (u64)(index1 - index0) << m_indexShift;
|
||||
|
||||
if (!compressed) {
|
||||
// Just read directly, easy.
|
||||
|
|
|
@ -63,7 +63,7 @@ static Access* ReadIndexFromFile(const wxString& filename) {
|
|||
infile.read((char*)index, sizeof(Access));
|
||||
|
||||
s64 datasize = size - GZIP_ID_LEN - sizeof(Access);
|
||||
if (datasize != index->have * sizeof(Point)) {
|
||||
if (datasize != (s64)index->have * sizeof(Point)) {
|
||||
Console.Error(L"Error: unexpected size of gzip index, please delete it manually: '%s'.", WX_STR(filename));
|
||||
infile.close();
|
||||
free(index);
|
||||
|
@ -316,6 +316,7 @@ bool GzippedFileReader::OkIndex() {
|
|||
WriteIndexToFile((Access*)m_pIndex, indexfile);
|
||||
} else {
|
||||
Console.Error(L"ERROR (%d): index could not be generated for file '%s'", len, WX_STR(m_filename));
|
||||
free_index(index);
|
||||
InitZstates();
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -90,7 +90,8 @@ void InputIsoFile::BeginRead2(uint lsn)
|
|||
|
||||
int InputIsoFile::FinishRead3(u8* dst, uint mode)
|
||||
{
|
||||
int _offset, length;
|
||||
int _offset = 0;
|
||||
int length = 0;
|
||||
int ret = 0;
|
||||
|
||||
if(m_current_lsn < 0)
|
||||
|
|
|
@ -209,9 +209,10 @@ u32 IsoDirectory::GetFileSize( const wxString& filePath ) const
|
|||
|
||||
IsoFileDescriptor::IsoFileDescriptor()
|
||||
{
|
||||
lba = 0;
|
||||
size = 0;
|
||||
lba = 0;
|
||||
size = 0;
|
||||
flags = 0;
|
||||
memset(&date, 0, sizeof(date));
|
||||
}
|
||||
|
||||
IsoFileDescriptor::IsoFileDescriptor(const u8* data, int length)
|
||||
|
|
|
@ -303,6 +303,11 @@ local int build_index(FILE *in, PX_off_t span, struct access **built)
|
|||
}
|
||||
} while (ret != Z_STREAM_END);
|
||||
|
||||
if (index == NULL) {
|
||||
// Could happen if the start of the stream in Z_STREAM_END
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* clean up and return index (release unused entries in list) */
|
||||
(void)inflateEnd(&strm);
|
||||
index->list = (Point*)realloc(index->list, sizeof(struct point) * index->have);
|
||||
|
|
|
@ -509,7 +509,7 @@ void MTC0()
|
|||
}
|
||||
|
||||
int CPCOND0() {
|
||||
return ((dmacRegs.stat.CIS | ~dmacRegs.pcr.CPC) == 0x3ff);
|
||||
return (((dmacRegs.stat.CIS | ~dmacRegs.pcr.CPC) & 0x3FF) == 0x3ff);
|
||||
}
|
||||
|
||||
//#define CPCOND0 1
|
||||
|
|
|
@ -28,7 +28,8 @@ namespace R3000A
|
|||
"r0", "at", "v0", "v1", "a0", "a1","a2", "a3",
|
||||
"t0", "t1", "t2", "t3", "t4", "t5","t6", "t7",
|
||||
"s0", "s1", "s2", "s3", "s4", "s5","s6", "s7",
|
||||
"t8", "t9", "k0", "k1", "gp", "sp","fp", "ra"};
|
||||
"t8", "t9", "k0", "k1", "gp", "sp","fp", "ra"
|
||||
"HI", "LO" };
|
||||
|
||||
const char * const disRNameCP0[] = {
|
||||
"Index" , "Random" , "EntryLo0", "EntryLo1", "Context" , "PageMask" , "Wired" , "*Check me*",
|
||||
|
|
|
@ -869,6 +869,9 @@ void disMemAccess( std::string& output, const char* name, int cop = 0)
|
|||
case 2:
|
||||
rt = COP2_REG_FP[DECODE_FT];
|
||||
break;
|
||||
default:
|
||||
rt = "???";
|
||||
break;
|
||||
}
|
||||
|
||||
const char* rs = GPR_REG[DECODE_RS];
|
||||
|
|
|
@ -444,8 +444,10 @@ void DisassemblyFunction::generateBranchLines()
|
|||
};
|
||||
|
||||
LaneInfo lanes[NUM_LANES];
|
||||
for (int i = 0; i < NUM_LANES; i++)
|
||||
for (int i = 0; i < NUM_LANES; i++) {
|
||||
lanes[i].used = false;
|
||||
lanes[i].end = 0;
|
||||
}
|
||||
|
||||
u32 end = address+size;
|
||||
|
||||
|
@ -643,6 +645,7 @@ void DisassemblyFunction::load()
|
|||
macro = new DisassemblyMacro(cpu,opAddress);
|
||||
macro->setMacroMemory("sh",immediate,rt,2);
|
||||
funcPos += 4;
|
||||
break;
|
||||
case 0x2B: // sw
|
||||
macro = new DisassemblyMacro(cpu,opAddress);
|
||||
macro->setMacroMemory("sw",immediate,rt,4);
|
||||
|
@ -989,6 +992,8 @@ void DisassemblyData::createLines()
|
|||
}
|
||||
break;
|
||||
default:
|
||||
// Avoid a call to strlen with random data
|
||||
buffer[0] = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -413,8 +413,8 @@ bool parsePostfixExpression(PostfixExpression& exp, IExpressionFunctions* funcs,
|
|||
size_t num = 0;
|
||||
u64 opcode;
|
||||
std::vector<u64> valueStack;
|
||||
u64 arg[5];
|
||||
float fArg[5];
|
||||
u64 arg[5] = {0};
|
||||
float fArg[5] = {0};
|
||||
bool useFloat = false;
|
||||
|
||||
while (num < exp.size())
|
||||
|
|
|
@ -241,6 +241,7 @@ void SymbolMap::AddModule(const char *name, u32 address, u32 size) {
|
|||
|
||||
ModuleEntry mod;
|
||||
strncpy(mod.name, name, ARRAY_SIZE(mod.name));
|
||||
mod.name[ARRAY_SIZE(mod.name) - 1] = 0;
|
||||
mod.start = address;
|
||||
mod.size = size;
|
||||
mod.index = (int)modules.size() + 1;
|
||||
|
|
|
@ -156,7 +156,7 @@ void sio2_serialIn(u8 value){
|
|||
if (sio2.cmdlength) sio2.cmdlength--;
|
||||
sioWrite8(value);
|
||||
|
||||
if (sio2.packet.sendSize > BUFSIZE) {//asadr
|
||||
if (sio2.packet.sendSize >= BUFSIZE) {//asadr
|
||||
Console.Warning("*PCSX2*: sendSize >= %d", BUFSIZE);
|
||||
} else {
|
||||
sio2.buf[sio2.packet.sendSize] = sioRead8();
|
||||
|
@ -183,7 +183,7 @@ void sio2_fifoIn(u8 value){
|
|||
if (sio2.cmdlength) sio2.cmdlength--;
|
||||
SIODMAWrite(value);
|
||||
|
||||
if (sio2.packet.sendSize > BUFSIZE) {//asadr
|
||||
if (sio2.packet.sendSize >= BUFSIZE) {//asadr
|
||||
Console.WriteLn("*PCSX2*: sendSize >= %d", BUFSIZE);
|
||||
} else {
|
||||
sio2.buf[sio2.packet.sendSize] = sioRead8();
|
||||
|
|
|
@ -298,7 +298,8 @@ protected:
|
|||
volatile u32 m_mcdOpen;
|
||||
|
||||
public: // hack until we unsuck plugins...
|
||||
ScopedPtr<PluginStatus_t> m_info[PluginId_Count];
|
||||
// +1 to avoid out-of-bounds due to PluginId_Mcd which is above PluginId_Count
|
||||
ScopedPtr<PluginStatus_t> m_info[PluginId_Count + 1];
|
||||
|
||||
public:
|
||||
SysCorePlugins();
|
||||
|
|
|
@ -176,19 +176,21 @@ static __ri void __fastcall _vuFMACAdd(VURegs * VU, int reg, int xyzw) {
|
|||
if (VU->fmac[i].enable == 1) continue;
|
||||
break;
|
||||
}
|
||||
//if (i==8) Console.Error("*PCSX2*: error , out of fmacs %d", VU->cycle);
|
||||
|
||||
if (i < 8) {
|
||||
VUM_LOG("adding FMAC pipe[%d]; xyzw=%x", i, xyzw);
|
||||
|
||||
VUM_LOG("adding FMAC pipe[%d]; xyzw=%x", i, xyzw);
|
||||
|
||||
VU->fmac[i].enable = 1;
|
||||
VU->fmac[i].sCycle = VU->cycle;
|
||||
VU->fmac[i].Cycle = 3;
|
||||
VU->fmac[i].reg = reg;
|
||||
VU->fmac[i].xyzw = xyzw;
|
||||
VU->fmac[i].macflag = VU->macflag;
|
||||
VU->fmac[i].statusflag = VU->statusflag;
|
||||
VU->fmac[i].clipflag = VU->clipflag;
|
||||
VU->fmac[i].enable = 1;
|
||||
VU->fmac[i].sCycle = VU->cycle;
|
||||
VU->fmac[i].Cycle = 3;
|
||||
VU->fmac[i].reg = reg;
|
||||
VU->fmac[i].xyzw = xyzw;
|
||||
VU->fmac[i].macflag = VU->macflag;
|
||||
VU->fmac[i].statusflag = VU->statusflag;
|
||||
VU->fmac[i].clipflag = VU->clipflag;
|
||||
} else {
|
||||
//Console.Error("*PCSX2*: error , out of fmacs %d", VU->cycle);
|
||||
}
|
||||
}
|
||||
|
||||
static __ri void __fastcall _vuFDIVAdd(VURegs * VU, int cycles) {
|
||||
|
|
|
@ -948,7 +948,10 @@ void ConsoleLogFrame::DoFlushEvent( bool isPending )
|
|||
} while( --m_WaitingThreadsForFlush > 0 );
|
||||
|
||||
int count = m_sem_QueueFlushed.Count();
|
||||
while( count < 0 ) m_sem_QueueFlushed.Post();
|
||||
while( count < 0 ) {
|
||||
m_sem_QueueFlushed.Post();
|
||||
count = m_sem_QueueFlushed.Count();
|
||||
}
|
||||
}
|
||||
|
||||
m_pendingFlushMsg = isPending;
|
||||
|
|
|
@ -73,7 +73,7 @@ public:
|
|||
}
|
||||
|
||||
BaseBlockArray (s32 size) : _Reserved(0),
|
||||
_Size(0)
|
||||
_Size(0), blocks(NULL)
|
||||
{
|
||||
if(size > 0) {
|
||||
resize(size);
|
||||
|
|
|
@ -710,7 +710,7 @@ static void recResetRaw()
|
|||
|
||||
maxrecmem = 0;
|
||||
|
||||
memset(recConstBuf, 0, RECCONSTBUF_SIZE * sizeof(recConstBuf));
|
||||
memset(recConstBuf, 0, RECCONSTBUF_SIZE * sizeof(*recConstBuf));
|
||||
|
||||
if( s_pInstCache )
|
||||
memset( s_pInstCache, 0, sizeof(EEINST)*s_nInstCacheSize );
|
||||
|
|
|
@ -1670,6 +1670,8 @@ EXPORT_C GSReplay(char* lpszCmdLine, int renderer)
|
|||
sleep(1);
|
||||
} else {
|
||||
unsigned long end = timeGetTime();
|
||||
frame_number = std::max(1ul, frame_number); // avoid a potential division by 0
|
||||
|
||||
fprintf(stderr, "The %ld frames of the scene was render on %ldms\n", frame_number, end - start);
|
||||
fprintf(stderr, "A means of %fms by frame\n", (float)(end - start)/(float)frame_number);
|
||||
|
||||
|
|
|
@ -81,7 +81,8 @@ void GSRendererHW::SetScaling() {
|
|||
}
|
||||
|
||||
|
||||
printf("Frame buffer size set to %dx%d (%dx%d)\n", (m_width / m_upscale_multiplier), (m_height / m_upscale_multiplier), m_width, m_height);
|
||||
if (m_upscale_multiplier)
|
||||
printf("Frame buffer size set to %dx%d (%dx%d)\n", (m_width / m_upscale_multiplier), (m_height / m_upscale_multiplier), m_width, m_height);
|
||||
}
|
||||
|
||||
GSRendererHW::~GSRendererHW()
|
||||
|
@ -464,7 +465,8 @@ void GSRendererHW::Draw()
|
|||
{
|
||||
s = format("%05d_f%lld_rz0_%05x_%d.bmp", s_n, frame, context->ZBUF.Block(), context->ZBUF.PSM);
|
||||
|
||||
ds_tex->Save(root_hw+s);
|
||||
if (ds_tex)
|
||||
ds_tex->Save(root_hw+s);
|
||||
}
|
||||
|
||||
s_n++;
|
||||
|
|
|
@ -5250,7 +5250,7 @@ bool GSC_UrbanReign(const GSFrameInfo& fi, int& skip)
|
|||
{
|
||||
if(skip == 0)
|
||||
{
|
||||
if(fi.TME && fi.FBP==0x0000 && fi.TBP0==0x3980 && fi.FPSM==fi.TPSM && fi.TPSM == PSM_PSMCT32 && fi.TPSM ==0 && fi.FBMSK == 0x0)
|
||||
if(fi.TME && fi.FBP==0x0000 && fi.TBP0==0x3980 && fi.FPSM==fi.TPSM && fi.TPSM == PSM_PSMCT32 && fi.FBMSK == 0x0)
|
||||
{
|
||||
skip = 1;
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ static inline int wcsicmp(const wchar_t* w1, const wchar_t* w2) {
|
|||
static inline unsigned int timeGetTime() {
|
||||
struct timeval now;
|
||||
gettimeofday(&now, NULL);
|
||||
uint64_t ms = (now.tv_usec/1000) + (now.tv_sec * 1000);
|
||||
uint64_t ms = (now.tv_usec/1000) + ((uint64_t)now.tv_sec * 1000);
|
||||
return (ms & 0xFFFFFFFF); // MS code is u32 ...
|
||||
}
|
||||
|
||||
|
|
|
@ -171,15 +171,15 @@ void LoadConfig()
|
|||
}
|
||||
|
||||
u32 value;
|
||||
if (fscanf(f, "log = %d\n", &value) == 0) return;
|
||||
if (fscanf(f, "log = %d\n", &value) == 0) goto error;
|
||||
conf->log = value;
|
||||
if (fscanf(f, "options = %d\n", &value) == 0) return;
|
||||
if (fscanf(f, "options = %d\n", &value) == 0) goto error;
|
||||
conf->options = value;
|
||||
if (fscanf(f, "mouse_sensibility = %d\n", &value) == 0) return;
|
||||
if (fscanf(f, "mouse_sensibility = %d\n", &value) == 0) goto error;
|
||||
conf->sensibility = value;
|
||||
if (fscanf(f, "joy_pad_map = %d\n", &value) == 0) return;
|
||||
if (fscanf(f, "joy_pad_map = %d\n", &value) == 0) goto error;
|
||||
conf->joyid_map = value;
|
||||
if (fscanf(f, "ff_intensity = %d\n", &value) == 0) return;
|
||||
if (fscanf(f, "ff_intensity = %d\n", &value) == 0) goto error;
|
||||
conf->ff_intensity = value;
|
||||
|
||||
for (int pad = 0; pad < 2; pad++)
|
||||
|
@ -199,11 +199,13 @@ void LoadConfig()
|
|||
u32 keysym;
|
||||
u32 index;
|
||||
while( fscanf(f, "PAD %d:KEYSYM 0x%x = %d\n", &pad, &keysym, &index) != EOF ) {
|
||||
set_keyboad_key(pad, keysym, index);
|
||||
set_keyboad_key(pad & 1, keysym, index);
|
||||
if(pad == 0) have_user_setting = true;
|
||||
}
|
||||
|
||||
if (!have_user_setting) DefaultKeyboardValues();
|
||||
|
||||
error:
|
||||
fclose(f);
|
||||
|
||||
if (!have_user_setting) DefaultKeyboardValues();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue