diff options
author | Vas Crabb <vas@vastheman.com> | 2022-08-03 02:27:49 +1000 |
---|---|---|
committer | Vas Crabb <vas@vastheman.com> | 2022-08-03 02:27:49 +1000 |
commit | 7cc3481d8ff8893fa8a5ccef4cffd97d73403bc0 (patch) | |
tree | 4c0c2f68a4c0298fee81a5430c318bfc2e2158f5 /src/emu/debug/debugcmd.cpp | |
parent | 9bbf203c39fbd306772620f84de8f6cb2c20f926 (diff) |
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.
Diffstat (limited to 'src/emu/debug/debugcmd.cpp')
-rw-r--r-- | src/emu/debug/debugcmd.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
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<std::string_view> } // 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<std::string endoffset++; // open the file - std::string filename(params[0]); + std::string const filename(params[0]); FILE *const f = fopen(filename.c_str(), "wb"); if (!f) { @@ -2411,7 +2411,7 @@ void debugger_commands::execute_saveregion(const std::vector<std::string_view> & 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<std::string // open the file std::ifstream f; - std::string fname(params[0]); - f.open(fname.c_str(), std::ifstream::in | std::ifstream::binary); + std::string const fname(params[0]); + f.open(fname, std::ifstream::in | std::ifstream::binary); if (f.fail()) { m_console.printf("Error opening file '%s'\n", params[0]); @@ -3770,8 +3770,7 @@ void debugger_commands::execute_trace(const std::vector<std::string_view> ¶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<std::string_view> ¶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 |