From 296934af365ea347aa94bdc88cf9e12b5e5031e8 Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Sat, 19 Nov 2022 17:41:37 -0800 Subject: cleanup: Replace static_cast with runtime cast The runtime cast is defined anyway by the GObject macros, and allows turning runtime checking on or off at build time as desired. --- gjs/console.cpp | 2 +- gjs/profiler.cpp | 2 +- gjs/stack.cpp | 2 +- test/gjs-tests.cpp | 6 ++---- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/gjs/console.cpp b/gjs/console.cpp index 3d53ade0..c2e15789 100644 --- a/gjs/console.cpp +++ b/gjs/console.cpp @@ -355,7 +355,7 @@ int main(int argc, char** argv) { if (coverage_prefixes) gjs_coverage_enable(); - GjsAutoUnref js_context(static_cast(g_object_new( + GjsAutoUnref js_context(GJS_CONTEXT(g_object_new( GJS_TYPE_CONTEXT, "search-path", include_path.get(), "program-name", program_name, "program-path", program_path.get(), "profiler-enabled", enable_profiler, "exec-as-module", exec_as_module, nullptr))); diff --git a/gjs/profiler.cpp b/gjs/profiler.cpp index 39c19621..1a5560f7 100644 --- a/gjs/profiler.cpp +++ b/gjs/profiler.cpp @@ -653,7 +653,7 @@ gjs_profiler_stop(GjsProfiler *self) static gboolean gjs_profiler_sigusr2(void *data) { - auto context = static_cast(data); + GjsContext* context = GJS_CONTEXT(data); GjsProfiler *current_profiler = gjs_context_get_profiler(context); if (current_profiler) { diff --git a/gjs/stack.cpp b/gjs/stack.cpp index b3d0d9c3..3292eae4 100644 --- a/gjs/stack.cpp +++ b/gjs/stack.cpp @@ -31,7 +31,7 @@ gjs_dumpstack(void) GList *iter; for (iter = contexts; iter; iter = iter->next) { - GjsAutoUnref context(static_cast(iter->data)); + GjsAutoUnref context(GJS_CONTEXT(iter->data)); gjs_context_print_stack_stderr(context); } } diff --git a/test/gjs-tests.cpp b/test/gjs-tests.cpp index e48734aa..7d46e286 100644 --- a/test/gjs-tests.cpp +++ b/test/gjs-tests.cpp @@ -814,10 +814,8 @@ gjstest_test_func_util_misc_strv_concat_pointers(void) static void gjstest_test_profiler_start_stop(void) { - GjsAutoUnref context = - static_cast(g_object_new(GJS_TYPE_CONTEXT, - "profiler-enabled", TRUE, - nullptr)); + GjsAutoUnref context = GJS_CONTEXT( + g_object_new(GJS_TYPE_CONTEXT, "profiler-enabled", TRUE, nullptr)); GjsProfiler *profiler = gjs_context_get_profiler(context); gjs_profiler_set_filename(profiler, "dont-conflict-with-other-test.syscap"); -- cgit v1.2.1