summaryrefslogtreecommitdiffstatshomepage
path: root/src/osd
diff options
context:
space:
mode:
authorGravatarGravatar Vas Crabb <vas@vastheman.com>2019-09-20 02:26:16 +1000
committerGravatarGravatar Vas Crabb <vas@vastheman.com>2019-09-20 02:26:16 +1000
commit8b233839ba630012026321070d77153fdf5a19b2 (patch)
tree6eaa5e7bdf8bb413a1abbcce95284917d75d1f76 /src/osd
parent37b02ce7de385c5c0a32853e52a861b8ff329077 (diff)
(nw) get rid of the rest of assert_always - it's better to be explicit about what this thing is supposed to do
Diffstat (limited to 'src/osd')
-rw-r--r--src/osd/modules/diagnostics/diagnostics_win32.cpp12
-rw-r--r--src/osd/modules/osdmodule.cpp19
-rw-r--r--src/osd/modules/osdwindow.h6
-rw-r--r--src/osd/modules/render/drawogl.cpp5
4 files changed, 25 insertions, 17 deletions
diff --git a/src/osd/modules/diagnostics/diagnostics_win32.cpp b/src/osd/modules/diagnostics/diagnostics_win32.cpp
index 3bd1e48fa10..677cd93bff7 100644
--- a/src/osd/modules/diagnostics/diagnostics_win32.cpp
+++ b/src/osd/modules/diagnostics/diagnostics_win32.cpp
@@ -670,16 +670,20 @@ sampling_profiler::~sampling_profiler()
void sampling_profiler::start()
{
// do the dance to get a handle to ourself
- BOOL result = DuplicateHandle(GetCurrentProcess(), GetCurrentThread(), GetCurrentProcess(), &m_target_thread,
- THREAD_GET_CONTEXT | THREAD_SUSPEND_RESUME | THREAD_QUERY_INFORMATION, FALSE, 0);
- assert_always(result, "Failed to get thread handle for main thread");
+ BOOL const result = DuplicateHandle(
+ GetCurrentProcess(), GetCurrentThread(),
+ GetCurrentProcess(), &m_target_thread,
+ THREAD_GET_CONTEXT | THREAD_SUSPEND_RESUME | THREAD_QUERY_INFORMATION, FALSE, 0);
+ if (!result)
+ throw emu_fatalerror("sampling_profiler::start: Failed to get thread handle for main thread");
// reset the exit flag
m_thread_exit = false;
// start the thread
m_thread = CreateThread(nullptr, 0, thread_entry, (LPVOID)this, 0, &m_thread_id);
- assert_always(m_thread != nullptr, "Failed to create profiler thread\n");
+ if (!m_thread)
+ throw emu_fatalerror("sampling_profiler::start: Failed to create profiler thread");
// max out the priority
SetThreadPriority(m_thread, THREAD_PRIORITY_TIME_CRITICAL);
diff --git a/src/osd/modules/osdmodule.cpp b/src/osd/modules/osdmodule.cpp
index 45664295cfb..75adc5c75bb 100644
--- a/src/osd/modules/osdmodule.cpp
+++ b/src/osd/modules/osdmodule.cpp
@@ -7,6 +7,9 @@
#include "modules/osdmodule.h"
+#include <algorithm>
+
+
osd_module_manager::osd_module_manager()
{
for (int i=0; i<MAX_MODULES; i++)
@@ -25,17 +28,15 @@ osd_module_manager::~osd_module_manager()
void osd_module_manager::register_module(const module_type &mod_type)
{
+ auto const slot = std::find(std::begin(m_modules), std::end(m_modules), nullptr);
+ if (std::end(m_modules) == slot)
+ throw emu_fatalerror("osd_module_manager::register_module: Module registration beyond MAX_MODULES!");
+
osd_module *module = mod_type();
if (module->probe())
{
osd_printf_verbose("===> registered module %s %s\n", module->name(), module->type());
-
- int i;
- for (i = 0; i < MAX_MODULES && m_modules[i] != nullptr; i++)
- ;
-
- assert_always(i < MAX_MODULES, "Module registration beyond MAX_MODULES!");
- m_modules[i] = module;
+ *slot = module;
}
else
{
@@ -51,8 +52,8 @@ bool osd_module_manager::type_has_name(const char *type, const char *name) const
osd_module *osd_module_manager::get_module_generic(const char *type, const char *name)
{
- int i = get_module_index(type, name);
- if (i>=0)
+ int const i = get_module_index(type, name);
+ if (i >= 0)
return m_modules[i];
else
return nullptr;
diff --git a/src/osd/modules/osdwindow.h b/src/osd/modules/osdwindow.h
index 506b4978161..3fe020c56fe 100644
--- a/src/osd/modules/osdwindow.h
+++ b/src/osd/modules/osdwindow.h
@@ -178,14 +178,16 @@ public:
static const int FLAG_NEEDS_ASYNCBLIT = 0x0200;
osd_renderer(std::shared_ptr<osd_window> window, const int flags)
- : m_sliders_dirty(false), m_window(window), m_flags(flags) { }
+ : m_sliders_dirty(false), m_window(window), m_flags(flags)
+ { }
virtual ~osd_renderer() { }
std::shared_ptr<osd_window> assert_window() const
{
auto win = m_window.lock();
- assert_always(win != nullptr, "Window weak_ptr is not available!");
+ if (!win)
+ throw emu_fatalerror("osd_renderer::assert_window: Window weak_ptr is not available!");
return win;
}
diff --git a/src/osd/modules/render/drawogl.cpp b/src/osd/modules/render/drawogl.cpp
index bd4648be474..6837e63bbe3 100644
--- a/src/osd/modules/render/drawogl.cpp
+++ b/src/osd/modules/render/drawogl.cpp
@@ -2026,10 +2026,11 @@ ogl_texture_info *renderer_ogl::texture_create(const render_texinfo *texsource,
m_texhash[i] = texture;
break;
}
- assert_always(i < HASH_SIZE + OVERFLOW_SIZE, "texture hash exhausted ...");
+ if ((HASH_SIZE + OVERFLOW_SIZE) <= i)
+ throw emu_fatalerror("renderer_ogl::texture_create: texture hash exhausted ...");
}
- if(m_usevbo)
+ if (m_usevbo)
{
// Generate And Bind The Texture Coordinate Buffer
pfn_glGenBuffers( 1, &(texture->texCoordBufferName) );