From 52fa9421b99f30e668415b76c1f5fe59f237258c Mon Sep 17 00:00:00 2001 From: "therealmogminer@gmail.com" Date: Fri, 6 Nov 2015 14:02:51 +0100 Subject: [PATCH] - Fix some instances of PVS-Studio warning V501, "There are identical sub- expressions to the left and to the right of an operator". [MooglyGuy] --- src/devices/cpu/alto2/a2emu.c | 7 ++++++- src/devices/machine/hdc92x4.c | 2 +- src/devices/video/315_5313.c | 5 +---- src/devices/video/mos6566.c | 2 +- src/lib/formats/ap2_dsk.c | 2 +- src/osd/modules/opengl/gl_shader_tool.c | 2 +- 6 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/devices/cpu/alto2/a2emu.c b/src/devices/cpu/alto2/a2emu.c index d5475fccef5..9152f936002 100644 --- a/src/devices/cpu/alto2/a2emu.c +++ b/src/devices/cpu/alto2/a2emu.c @@ -606,7 +606,12 @@ void alto2_cpu_device::f2_late_idisp() r = IR_SH(m_emu.ir) ^ 3; /* complement of SH */ LOG((this,LOG_EMU,2," IDISP<-; branch on SH^3 (%#o|%#o)\n", m_next2, r)); } else { - int addr = CTL2K_U3(f2_emu_idisp) + X_RDBITS(m_emu.ir,16,1,7); + //int addr = CTL2K_U3(f2_emu_idisp) + X_RDBITS(m_emu.ir,16,1,7); + // The above line triggers the following warning in PVS-Studio: + // V501: There are identical sub-expressions to the left and to the right of the '==' operator: f2_emu_idisp == f2_emu_idisp + // This is because CTL2K_U3(f2) checks f2 == f2_emu_idisp, and so will always evaluate to true in this case. + // Consider checking if this is a typo or if it is correct. + int addr = 0x80 + X_RDBITS(m_emu.ir,16,1,7); /* 0???????xxxxxxxx */ r = m_ctl2k_u3[addr]; LOG((this,LOG_EMU,2," IDISP<-; IR (%#o) branch on PROM ctl2k_u3[%03o] (%#o|%#o)\n", m_emu.ir, addr, m_next2, r)); diff --git a/src/devices/machine/hdc92x4.c b/src/devices/machine/hdc92x4.c index 4b4253cfa8c..5f6b6f20eb1 100644 --- a/src/devices/machine/hdc92x4.c +++ b/src/devices/machine/hdc92x4.c @@ -1911,7 +1911,7 @@ bool hdc92x4_device::found_mark(int state) bool ismark = false; if (using_floppy()) { - if (state==SEARCH_IDAM) ismark = (m_live_state.shift_reg == fm_mode()? 0xf57e : 0x4489); + if (state==SEARCH_IDAM) ismark = (m_live_state.shift_reg == fm_mode() ? 0xf57e : 0x4489); else { // f56a 1x1x diff --git a/src/devices/video/315_5313.c b/src/devices/video/315_5313.c index 96fae6a18e3..88c21c7dc18 100644 --- a/src/devices/video/315_5313.c +++ b/src/devices/video/315_5313.c @@ -1022,11 +1022,8 @@ UINT16 sega315_5313_device::ctrl_port_r() d0 - PAL mode flag */ - return (0<<15) | // ALWAYS 0 - (0<<14) | // ALWAYS 0 - (1<<13) | // ALWAYS 1 + return (1<<13) | // ALWAYS 1 (1<<12) | // ALWAYS 1 - (0<<11) | // ALWAYS 0 (1<<10) | // ALWAYS 1 (fifo_empty<<9 ) | // FIFO EMPTY (fifo_full<<8 ) | // FIFO FULL diff --git a/src/devices/video/mos6566.c b/src/devices/video/mos6566.c index 64b061c3107..f7888869c25 100644 --- a/src/devices/video/mos6566.c +++ b/src/devices/video/mos6566.c @@ -129,7 +129,7 @@ static const rgb_t PALETTE_MOS[] = } \ } while (0) -#define IS_PAL ((m_variant == TYPE_6569) || (m_variant == TYPE_6572) || (m_variant == TYPE_6573) || (m_variant == TYPE_8565) || (m_variant == TYPE_8565) || (m_variant == TYPE_8569)) +#define IS_PAL ((m_variant == TYPE_6569) || (m_variant == TYPE_6572) || (m_variant == TYPE_6573) || (m_variant == TYPE_8565) || (m_variant == TYPE_8569)) #define IS_VICIIE ((m_variant == TYPE_8564) || (m_variant == TYPE_8566) || (m_variant == TYPE_8569)) #define ROW25_YSTART 0x33 diff --git a/src/lib/formats/ap2_dsk.c b/src/lib/formats/ap2_dsk.c index e20b96e438a..885332882f9 100644 --- a/src/lib/formats/ap2_dsk.c +++ b/src/lib/formats/ap2_dsk.c @@ -1626,7 +1626,7 @@ bool a2_edd_format::load(io_generic *io, UINT32 form_factor, floppy_image *image odd = !odd; int splice_byte = spos; - while(splice_byte < spos+delta && (npos[splice_byte+1] - npos[splice_byte] != 8 || npos[splice_byte+2] - npos[splice_byte+1] == 8 || npos[splice_byte+2] - npos[splice_byte+2] == 8)) + while(splice_byte < spos+delta && (npos[splice_byte+1] - npos[splice_byte] != 8 || npos[splice_byte+2] - npos[splice_byte+1] == 8 || npos[splice_byte+3] - npos[splice_byte+2] == 8)) splice_byte++; int splice = (npos[splice_byte+2]-1) % len; if(odd) diff --git a/src/osd/modules/opengl/gl_shader_tool.c b/src/osd/modules/opengl/gl_shader_tool.c index 203869e308e..8281691a607 100644 --- a/src/osd/modules/opengl/gl_shader_tool.c +++ b/src/osd/modules/opengl/gl_shader_tool.c @@ -69,7 +69,7 @@ int gl_shader_loadExtention(osd_gl_context *gl_ctx) if ( pfn_glGetObjectParameterivARB && pfn_glGetInfoLogARB && pfn_glDeleteObjectARB && pfn_glCreateShaderObjectARB && pfn_glShaderSourceARB && pfn_glCompileShaderARB && pfn_glCreateProgramObjectARB && pfn_glAttachObjectARB && - pfn_glLinkProgramARB && pfn_glValidateProgramARB && pfn_glUseProgramObjectARB && pfn_glGetUniformLocationARB && + pfn_glLinkProgramARB && pfn_glValidateProgramARB && pfn_glUseProgramObjectARB && pfn_glGetUniformLocationARB && pfn_glUniform1fARB && pfn_glUniform1iARB && pfn_glUniform1fvARB && pfn_glUniform2fvARB && pfn_glUniform3fvARB && pfn_glUniform4fvARB && pfn_glUniform1ivARB && pfn_glUniform2ivARB && pfn_glUniform3ivARB && pfn_glUniform4ivARB