From 7cc3481d8ff8893fa8a5ccef4cffd97d73403bc0 Mon Sep 17 00:00:00 2001 From: Vas Crabb Date: Wed, 3 Aug 2022 02:27:49 +1000 Subject: ui/icorender.cpp: Revert initialisations that can hide real bugs. MSVC isn't smart enough to detect that these can only be used after being assigned while clang and GCC can work it out fine. Initialising them to zero at declaration has the potential to mask real bugs if some code path tries to use them without assigning them. Code flow analysis (e.g. Coverity) or memory analysers (e.g. valgrind or Purify) won't pick up on the buggy path because the variable will technically be initialised. MSVC is problematic when it comes to warnings about uninitialised variables in general. Unfortunately MSVC has no option to selectively treat warnings as errors, unlike clang/GCC which have -Wno-error= which we use extensively. Until Microsoft addresses these issues, you'll have to use NOWERROR=1 when building with MSVC. Also, some cleanup. --- src/emu/debug/debugcmd.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'src/emu/debug/debugcmd.cpp') diff --git a/src/emu/debug/debugcmd.cpp b/src/emu/debug/debugcmd.cpp index 064f102299c..7ef0110031e 100644 --- a/src/emu/debug/debugcmd.cpp +++ b/src/emu/debug/debugcmd.cpp @@ -1707,7 +1707,7 @@ void debugger_commands::execute_comment_add(const std::vector } // Now try adding the comment - std::string text(params[1]); + std::string const text(params[1]); cpu->debug()->comment_add(address, text.c_str(), 0x00ff0000); cpu->machine().debug_view().update_all(DVT_DISASSEMBLY); } @@ -2318,7 +2318,7 @@ void debugger_commands::execute_save(int spacenum, const std::vector & length = region->bytes() - offset; /* open the file */ - std::string filename(params[0]); + std::string const filename(params[0]); FILE *f = fopen(filename.c_str(), "wb"); if (!f) { @@ -2442,8 +2442,8 @@ void debugger_commands::execute_load(int spacenum, const std::vector ¶m if (params.size() > 2) { std::stringstream stream; - std::string flagparam(params[2]); - stream.str(flagparam); + stream.str(std::string(params[2])); std::string flag; while (std::getline(stream, flag, '|')) @@ -3812,7 +3811,7 @@ void debugger_commands::execute_trace(const std::vector ¶m } // do it - cpu->debug()->trace(f, trace_over, detect_loops, logerror, action.c_str()); + cpu->debug()->trace(f, trace_over, detect_loops, logerror, action.c_str()); if (f) m_console.printf("Tracing CPU '%s' to file %s\n", cpu->tag(), filename); else -- cgit v1.2.3