gsdx: initialize members in constructor of objects

A couple of useless members were removed too.

Also fix wnd initialization

Coverity:
CID 146955 (#1 of 1): Uninitialized pointer read (UNINIT)
18. uninit_use: Using uninitialized value wnd[i].
This commit is contained in:
Gregory Hainaut 2015-09-11 12:19:49 +02:00
parent c4a3d57499
commit 5fb8c7e65c
19 changed files with 45 additions and 24 deletions

View File

@ -194,7 +194,7 @@ static int _GSopen(void** dsp, char* title, int renderer, int threads = -1)
threads = theApp.GetConfig("extrathreads", 0);
}
GSWnd* wnd[2];
GSWnd* wnd[2] = { NULL, NULL };
try
{
@ -315,7 +315,6 @@ static int _GSopen(void** dsp, char* title, int renderer, int threads = -1)
wnd[1] = new GSWndOGL();
#else
wnd[0] = new GSWndOGL();
wnd[1] = NULL;
#endif
#endif
}

View File

@ -35,6 +35,7 @@ GSDevice::GSDevice()
, m_fxaa(NULL)
, m_shadeboost(NULL)
, m_1x1(NULL)
, m_current(NULL)
, m_frame(0)
{
memset(&m_vertex, 0, sizeof(m_vertex));

View File

@ -46,12 +46,16 @@ int GSDeviceOGL::s_n = 0;
FILE* GSDeviceOGL::m_debug_gl_file = NULL;
GSDeviceOGL::GSDeviceOGL()
: m_free_window(false)
, m_window(NULL)
, m_fbo(0)
, m_fbo_read(0)
, m_va(NULL)
, m_shader(NULL)
: m_msaa(0)
, m_window(NULL)
, m_fbo(0)
, m_fbo_read(0)
, m_va(NULL)
, m_apitrace(0)
, m_palette_ss(0)
, m_vs_cb(NULL)
, m_ps_cb(NULL)
, m_shader(NULL)
{
memset(&m_merge_obj, 0, sizeof(m_merge_obj));
memset(&m_interlace, 0, sizeof(m_interlace));
@ -59,6 +63,8 @@ GSDeviceOGL::GSDeviceOGL()
memset(&m_fxaa, 0, sizeof(m_fxaa));
memset(&m_shaderfx, 0, sizeof(m_shaderfx));
memset(&m_date, 0, sizeof(m_date));
memset(&m_shadeboost, 0, sizeof(m_shadeboost));
memset(&m_om_dss, 0, sizeof(m_om_dss));
GLState::Clear();
// Reset the debug file

View File

@ -390,7 +390,6 @@ class GSDeviceOGL : public GSDevice
static bool m_debug_gl_call;
static FILE* m_debug_gl_file;
bool m_free_window;
GSWnd* m_window;
GLuint m_fbo; // frame buffer container
@ -446,7 +445,6 @@ class GSDeviceOGL : public GSDevice
GLuint m_apitrace;
GLuint m_palette_ss;
GLuint m_rt_ss;
GSUniformBufferOGL* m_vs_cb;
GSUniformBufferOGL* m_ps_cb;

View File

@ -25,6 +25,7 @@
GSDump::GSDump()
: m_gs(NULL)
, m_frames(0)
, m_extra_frames(0)
{
}

View File

@ -130,6 +130,11 @@ GSDumpLzma::~GSDumpLzma() {
/******************************************************************/
GSDumpRaw::GSDumpRaw(char* filename) : GSDumpFile(filename) {
m_buff_size = 0;
m_area = NULL;
m_inbuf = NULL;
m_avail = 0;
m_start = 0;
}
GSDumpRaw::~GSDumpRaw() {

View File

@ -48,7 +48,6 @@ class GSDumpLzma : public GSDumpFile {
size_t m_avail;
size_t m_start;
bool m_eof;
void Decompress();
@ -70,7 +69,6 @@ class GSDumpRaw : public GSDumpFile {
size_t m_avail;
size_t m_start;
bool m_eof;
void Decompress();

View File

@ -29,6 +29,8 @@ GSRenderer::GSRenderer()
: m_shader(0)
, m_shift_key(false)
, m_control_key(false)
, m_framelimit(false)
, m_texture_shuffle(false)
, m_wnd(NULL)
, m_dev(NULL)
{

View File

@ -30,7 +30,6 @@ class GSRenderer : public GSState
{
GSCapture m_capture;
string m_snapshot;
bool m_snapdump;
int m_shader;
bool Merge(int field);

View File

@ -49,21 +49,21 @@ GSRendererHW::GSRendererHW(GSTextureCache* tc)
void GSRendererHW::SetScaling()
{
m_buffer_size = max(m_context->FRAME.FBW * 64, m_regs->DISP[m_regs->PMODE.EN1 == 1 ? 0 : 1].DISPFB.FBW * 64);
int buffer_size = max(m_context->FRAME.FBW * 64, m_regs->DISP[m_regs->PMODE.EN1 == 1 ? 0 : 1].DISPFB.FBW * 64);
//Only increase the buffer size, don't make it smaller, it breaks games (GH3)
// Also don't change the size for custom resolution (m_upscale_multiplier = 0).
if (m_upscale_multiplier && m_width < (m_buffer_size * m_upscale_multiplier)) {
if (m_upscale_multiplier && m_width < (buffer_size * m_upscale_multiplier)) {
m_tc->RemovePartial();
} else {
return;
}
m_height = m_buffer_size < 1024 ? 512 : 1024;
m_height = buffer_size < 1024 ? 512 : 1024;
if (m_upscale_multiplier > 1) {
m_width = m_buffer_size * m_upscale_multiplier;
m_width = buffer_size * m_upscale_multiplier;
m_height *= m_upscale_multiplier;
}

View File

@ -35,7 +35,6 @@ private:
int m_skip;
bool m_reset;
int m_upscale_multiplier;
int m_buffer_size;
int m_userhacks_skipdraw;
bool m_userhacks_align_sprite_X;

View File

@ -35,6 +35,8 @@ GSRendererOGL::GSRendererOGL()
UserHacks_TCO_x = (UserHacks_TCOffset & 0xFFFF) / -1000.0f;
UserHacks_TCO_y = ((UserHacks_TCOffset >> 16) & 0xFFFF) / -1000.0f;
m_prim_overlap = PRIM_OVERLAP_UNKNOW;
if (!theApp.GetConfig("UserHacks", 0)) {
UserHacks_TCOffset = 0;
UserHacks_TCO_x = 0;

View File

@ -1534,6 +1534,8 @@ GSRendererSW::SharedData::SharedData(GSRendererSW* parent)
: m_parent(parent)
, m_fb_pages(NULL)
, m_zb_pages(NULL)
, m_fpsm(0)
, m_zpsm(0)
, m_using_pages(false)
, m_syncpoint(SyncNone)
{

View File

@ -24,6 +24,7 @@
#include "GLState.h"
GSShaderOGL::GSShaderOGL(bool debug) :
m_pipeline(0),
m_debug_shader(debug)
{
m_single_prog.clear();

View File

@ -26,7 +26,11 @@ GSTexture::GSTexture()
: m_scale(1, 1)
, m_size(0, 0)
, m_type(0)
, m_format(0)
, m_msaa(false)
, last_frame_used(0)
, LikelyOffset(false)
, OffsetHack_modx(0.0f)
, OffsetHack_mody(0.0f)
{
}

View File

@ -1251,6 +1251,7 @@ GSTextureCache::Source::Source(GSRenderer* r, const GIFRegTEX0& TEX0, const GIFR
, m_initpalette(true)
, m_target(false)
, m_complete(false)
, m_spritehack_t(false)
, m_p2t(NULL)
{
m_TEX0 = TEX0;

View File

@ -60,11 +60,11 @@ class GSBufferOGL {
// Warning m_limit is the number of object (not the size in Bytes)
m_limit = 8 * 1024 * 1024 / m_stride;
if (m_buffer_storage) {
for (size_t i = 0; i < 5; i++) {
m_fence[i] = 0;
}
for (size_t i = 0; i < 5; i++) {
m_fence[i] = 0;
}
if (m_buffer_storage) {
// TODO: if we do manually the synchronization, I'm not sure size is important. It worths to investigate it.
// => bigger buffer => less sync
bind();
@ -254,7 +254,7 @@ class GSVertexBufferStateOGL {
GLenum m_topology;
public:
GSVertexBufferStateOGL(size_t stride, GSInputLayoutOGL* layout, uint32 layout_nbr) : m_vb(NULL), m_ib(NULL)
GSVertexBufferStateOGL(size_t stride, GSInputLayoutOGL* layout, uint32 layout_nbr) : m_vb(NULL), m_ib(NULL), m_topology(0)
{
gl_GenVertexArrays(1, &m_va);
gl_BindVertexArray(m_va);

View File

@ -29,6 +29,9 @@ const GSVector4 GSVertexTrace::s_minmax(FLT_MAX, -FLT_MAX);
GSVertexTrace::GSVertexTrace(const GSState* state)
: m_state(state)
{
m_primclass = GS_INVALID_CLASS;
memset(&m_alpha, 0, sizeof(m_alpha));
#define InitUpdate3(P, IIP, TME, FST, COLOR) \
m_fmm[COLOR][FST][TME][IIP][P] = &GSVertexTrace::FindMinMax<P, IIP, TME, FST, COLOR>;

View File

@ -24,7 +24,7 @@
#if defined(__linux__)
GSWndOGL::GSWndOGL()
: m_NativeWindow(0), m_NativeDisplay(NULL), m_swapinterval(NULL)
: m_NativeWindow(0), m_NativeDisplay(NULL), m_context(0), m_swapinterval(NULL)
{
}