[retro-gtk] Only use g_return_(val_)if_fail() for public API
- From: Adrien Plazas <aplazas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [retro-gtk] Only use g_return_(val_)if_fail() for public API
- Date: Sat, 29 Feb 2020 06:45:10 +0000 (UTC)
commit 47b5f1b5c7a03693df58e5247f3db1694cffeeb0
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Sat Feb 22 18:30:32 2020 +0500
Only use g_return_(val_)if_fail() for public API
Stop using them in static functions. Replace them with g_assert() where
it makes sense, or just remove them.
retro-gtk/retro-cairo-display.c | 14 ++---
retro-gtk/retro-core-descriptor.c | 41 +++++-------
retro-gtk/retro-core-view-controller.c | 6 --
retro-gtk/retro-core-view.c | 38 ++---------
retro-gtk/retro-core.c | 4 --
retro-gtk/retro-gl-display.c | 13 ++--
retro-gtk/retro-module-iterator.c | 17 ++---
retro-runner/ipc-runner-impl.c | 112 +++++----------------------------
retro-runner/retro-core.c | 34 ++--------
retro-runner/retro-module.c | 2 +-
retro-runner/retro-pa-player.c | 2 -
tests/retro-reftest.c | 10 ---
tests/retro-test-controller.c | 4 --
13 files changed, 54 insertions(+), 243 deletions(-)
---
diff --git a/retro-gtk/retro-cairo-display.c b/retro-gtk/retro-cairo-display.c
index ffaf26f..e71502a 100644
--- a/retro-gtk/retro-cairo-display.c
+++ b/retro-gtk/retro-cairo-display.c
@@ -38,11 +38,10 @@ retro_cairo_display_get_video_box (RetroCairoDisplay *self,
gdouble display_ratio;
gdouble allocated_ratio;
- g_return_if_fail (self != NULL);
- g_return_if_fail (width != NULL);
- g_return_if_fail (height != NULL);
- g_return_if_fail (x != NULL);
- g_return_if_fail (y != NULL);
+ g_assert (width != NULL);
+ g_assert (height != NULL);
+ g_assert (x != NULL);
+ g_assert (y != NULL);
w = (gdouble) gtk_widget_get_allocated_width (GTK_WIDGET (self));
h = (gdouble) gtk_widget_get_allocated_height (GTK_WIDGET (self));
@@ -70,8 +69,7 @@ static void
retro_cairo_display_draw_background (RetroCairoDisplay *self,
cairo_t *cr)
{
- g_return_if_fail (self != NULL);
- g_return_if_fail (cr != NULL);
+ g_assert (cr != NULL);
cairo_set_source_rgb (cr, (gdouble) 0, (gdouble) 0, (gdouble) 0);
cairo_paint (cr);
@@ -249,8 +247,6 @@ retro_cairo_display_on_video_output (RetroCore *sender,
GdkPixbuf *pixbuf;
- g_return_if_fail (self != NULL);
-
self->aspect_ratio = retro_pixdata_get_aspect_ratio (pixdata);
pixbuf = retro_pixdata_to_pixbuf (pixdata);
retro_cairo_display_set_pixbuf (self, pixbuf);
diff --git a/retro-gtk/retro-core-descriptor.c b/retro-gtk/retro-core-descriptor.c
index 1313af7..cdea0ec 100644
--- a/retro-gtk/retro-core-descriptor.c
+++ b/retro-gtk/retro-core-descriptor.c
@@ -76,9 +76,8 @@ has_group_prefixed (RetroCoreDescriptor *self,
gchar *group;
gboolean result;
- g_return_val_if_fail (RETRO_IS_CORE_DESCRIPTOR (self), FALSE);
- g_return_val_if_fail (group_prefix != NULL, FALSE);
- g_return_val_if_fail (group_suffix != NULL, FALSE);
+ g_assert (group_prefix != NULL);
+ g_assert (group_suffix != NULL);
group = g_strconcat (group_prefix, group_suffix, NULL);
result = g_key_file_has_group (self->key_file, group);
@@ -98,10 +97,9 @@ has_key_prefixed (RetroCoreDescriptor *self,
gboolean result;
GError *tmp_error = NULL;
- g_return_val_if_fail (RETRO_IS_CORE_DESCRIPTOR (self), FALSE);
- g_return_val_if_fail (group_prefix != NULL, FALSE);
- g_return_val_if_fail (group_suffix != NULL, FALSE);
- g_return_val_if_fail (key != NULL, FALSE);
+ g_assert (group_prefix != NULL);
+ g_assert (group_suffix != NULL);
+ g_assert (key != NULL);
group = g_strconcat (group_prefix, group_suffix, NULL);
result = g_key_file_has_key (self->key_file,
@@ -131,10 +129,9 @@ get_string_prefixed (RetroCoreDescriptor *self,
gchar *result;
GError *tmp_error = NULL;
- g_return_val_if_fail (RETRO_IS_CORE_DESCRIPTOR (self), NULL);
- g_return_val_if_fail (group_prefix != NULL, NULL);
- g_return_val_if_fail (group_suffix != NULL, NULL);
- g_return_val_if_fail (key != NULL, NULL);
+ g_assert (group_prefix != NULL);
+ g_assert (group_suffix != NULL);
+ g_assert (key != NULL);
group = g_strconcat (group_prefix, group_suffix, NULL);
@@ -166,11 +163,10 @@ get_string_list_prefixed (RetroCoreDescriptor *self,
gchar **result;
GError *tmp_error = NULL;
- g_return_val_if_fail (RETRO_IS_CORE_DESCRIPTOR (self), NULL);
- g_return_val_if_fail (group_prefix != NULL, NULL);
- g_return_val_if_fail (group_suffix != NULL, NULL);
- g_return_val_if_fail (key != NULL, NULL);
- g_return_val_if_fail (length != NULL, NULL);
+ g_assert (group_prefix != NULL);
+ g_assert (group_suffix != NULL);
+ g_assert (key != NULL);
+ g_assert (length != NULL);
group = g_strconcat (group_prefix, group_suffix, NULL);
result = g_key_file_get_string_list (self->key_file,
@@ -199,9 +195,8 @@ retro_core_descriptor_check_has_required_key (RetroCoreDescriptor *self,
gboolean has_key;
GError *tmp_error = NULL;
- g_return_if_fail (RETRO_IS_CORE_DESCRIPTOR (self));
- g_return_if_fail (group != NULL);
- g_return_if_fail (key != NULL);
+ g_assert (group != NULL);
+ g_assert (key != NULL);
has_key = g_key_file_has_key (self->key_file,
RETRO_CORE_DESCRIPTOR_LIBRETRO_GROUP,
@@ -230,8 +225,6 @@ retro_core_descriptor_check_libretro_group (RetroCoreDescriptor *self,
{
GError *tmp_error = NULL;
- g_return_if_fail (RETRO_IS_CORE_DESCRIPTOR (self));
-
retro_core_descriptor_check_has_required_key (self,
RETRO_CORE_DESCRIPTOR_LIBRETRO_GROUP,
RETRO_CORE_DESCRIPTOR_TYPE_KEY,
@@ -284,8 +277,7 @@ retro_core_descriptor_check_platform_group (RetroCoreDescriptor *self,
gchar *firmware_group;
GError *tmp_error = NULL;
- g_return_if_fail (RETRO_IS_CORE_DESCRIPTOR (self));
- g_return_if_fail (group != NULL);
+ g_assert (group != NULL);
retro_core_descriptor_check_has_required_key (self,
group,
@@ -347,8 +339,7 @@ retro_core_descriptor_check_firmware_group (RetroCoreDescriptor *self,
{
GError *tmp_error = NULL;
- g_return_if_fail (RETRO_IS_CORE_DESCRIPTOR (self));
- g_return_if_fail (group != NULL);
+ g_assert (group != NULL);
retro_core_descriptor_check_has_required_key (self,
group,
diff --git a/retro-gtk/retro-core-view-controller.c b/retro-gtk/retro-core-view-controller.c
index eb62f40..94f8d45 100644
--- a/retro-gtk/retro-core-view-controller.c
+++ b/retro-gtk/retro-core-view-controller.c
@@ -27,8 +27,6 @@ retro_core_view_controller_get_input_state (RetroController *base,
gpointer view;
gint16 result;
- g_return_val_if_fail (self != NULL, 0);
-
if (retro_input_get_controller_type (input) != self->controller_type)
return 0;
@@ -49,8 +47,6 @@ retro_core_view_controller_get_controller_type (RetroController *base)
{
RetroCoreViewController *self = RETRO_CORE_VIEW_CONTROLLER (base);
- g_return_val_if_fail (self != NULL, 0);
-
return self->controller_type;
}
@@ -61,8 +57,6 @@ retro_core_view_controller_get_capabilities (RetroController *base)
gpointer view;
guint64 capabilities;
- g_return_val_if_fail (self != NULL, 0);
-
view = g_weak_ref_get (&self->view);
if (view == NULL)
diff --git a/retro-gtk/retro-core-view.c b/retro-gtk/retro-core-view.c
index 17472ca..8f42eac 100644
--- a/retro-gtk/retro-core-view.c
+++ b/retro-gtk/retro-core-view.c
@@ -110,8 +110,6 @@ recenter_pointer (RetroCoreView *self)
static gboolean
retro_core_view_get_is_pointer_grabbed (RetroCoreView *self)
{
- g_return_val_if_fail (RETRO_IS_CORE_VIEW (self), FALSE);
-
return self->grabbed_device != NULL;
}
@@ -128,10 +126,9 @@ retro_core_view_grab (RetroCoreView *self,
GdkMonitor *monitor;
GdkRectangle monitor_geometry;
- g_return_if_fail (RETRO_IS_CORE_VIEW (self));
- g_return_if_fail (device != NULL);
- g_return_if_fail (window != NULL);
- g_return_if_fail (event != NULL);
+ g_assert (device != NULL);
+ g_assert (window != NULL);
+ g_assert (event != NULL);
if (self->grabbed_device != NULL)
g_object_unref (self->grabbed_device);
@@ -166,8 +163,7 @@ retro_core_view_ungrab (RetroCoreView *self)
{
GdkSeat *seat;
- g_return_if_fail (RETRO_IS_CORE_VIEW (self));
- g_return_if_fail (self->grabbed_device != NULL);
+ g_assert (self->grabbed_device != NULL);
seat = gdk_device_get_seat (self->grabbed_device);
gdk_seat_ungrab (seat);
@@ -191,9 +187,6 @@ retro_core_view_on_key_press_event (GtkWidget *source,
RetroCoreView *self = RETRO_CORE_VIEW (data);
gboolean changed;
- g_return_val_if_fail (RETRO_IS_CORE_VIEW (self), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
if (event->keyval == GDK_KEY_Escape &&
(event->state & GDK_CONTROL_MASK) &&
retro_core_view_get_is_pointer_grabbed (self))
@@ -217,9 +210,6 @@ retro_core_view_on_key_release_event (GtkWidget *source,
{
RetroCoreView *self = RETRO_CORE_VIEW (data);
- g_return_val_if_fail (RETRO_IS_CORE_VIEW (self), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
set_input_released (self->key_state, event->hardware_keycode);
set_input_released (self->keyval_state, event->keyval);
@@ -235,9 +225,6 @@ retro_core_view_on_button_press_event (GtkWidget *source,
{
RetroCoreView *self = RETRO_CORE_VIEW (data);
- g_return_val_if_fail (RETRO_IS_CORE_VIEW (self), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
gtk_widget_grab_focus (GTK_WIDGET (source));
if (retro_core_view_get_can_grab_pointer (self)) {
@@ -271,9 +258,6 @@ retro_core_view_on_button_release_event (GtkWidget *source,
{
RetroCoreView *self = RETRO_CORE_VIEW (data);
- g_return_val_if_fail (RETRO_IS_CORE_VIEW (self), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
set_input_released (self->mouse_button_state, event->button);
g_signal_emit (self, signals[SIG_CONTROLLER_STATE_CHANGED_SIGNAL], 0);
@@ -288,9 +272,6 @@ retro_core_view_on_focus_out_event (GtkWidget *source,
{
RetroCoreView *self = RETRO_CORE_VIEW (data);
- g_return_val_if_fail (RETRO_IS_CORE_VIEW (self), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
if (retro_core_view_get_is_pointer_grabbed (self))
retro_core_view_ungrab (self);
@@ -309,9 +290,6 @@ retro_core_view_on_motion_notify_event (GtkWidget *source,
{
RetroCoreView *self = RETRO_CORE_VIEW (data);
- g_return_val_if_fail (RETRO_IS_CORE_VIEW (self), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
if (retro_core_view_get_can_grab_pointer (self)) {
if (retro_core_view_get_is_pointer_grabbed (self) &&
event->device == self->grabbed_device) {
@@ -340,8 +318,6 @@ static gboolean
retro_core_view_get_key_state (RetroCoreView *self,
guint16 hardware_keycode)
{
- g_return_val_if_fail (RETRO_IS_CORE_VIEW (self), FALSE);
-
return get_input_state (self->key_state, hardware_keycode);
}
@@ -351,8 +327,6 @@ retro_core_view_get_joypad_button_state (RetroCoreView *self,
{
guint16 hardware_keycode;
- g_return_val_if_fail (RETRO_IS_CORE_VIEW (self), FALSE);
-
if (button >= RETRO_JOYPAD_ID_COUNT)
return 0;
@@ -365,8 +339,6 @@ static gboolean
retro_core_view_get_mouse_button_state (RetroCoreView *self,
guint16 button)
{
- g_return_val_if_fail (RETRO_IS_CORE_VIEW (self), FALSE);
-
return get_input_state (self->mouse_button_state, button);
}
@@ -376,8 +348,6 @@ retro_core_view_get_keyboard_key_state (RetroCoreView *self,
{
guint16 keyval;
- g_return_val_if_fail (RETRO_IS_CORE_VIEW (self), FALSE);
-
if (key >= RETRO_KEYBOARD_KEY_LAST)
return FALSE;
diff --git a/retro-gtk/retro-core.c b/retro-gtk/retro-core.c
index 8b475e8..22fd990 100644
--- a/retro-gtk/retro-core.c
+++ b/retro-gtk/retro-core.c
@@ -160,8 +160,6 @@ retro_core_finalize (GObject *object)
RetroCore *self = RETRO_CORE (object);
gint i;
- g_return_if_fail (RETRO_IS_CORE (self));
-
retro_core_set_keyboard (self, NULL);
g_object_unref (self->framebuffer);
@@ -591,8 +589,6 @@ static void
retro_core_set_filename (RetroCore *self,
const gchar *filename)
{
- g_return_if_fail (RETRO_IS_CORE (self));
-
if (g_strcmp0 (filename, retro_core_get_filename (self)) == 0)
return;
diff --git a/retro-gtk/retro-gl-display.c b/retro-gtk/retro-gl-display.c
index e4e9f09..551f576 100644
--- a/retro-gtk/retro-gl-display.c
+++ b/retro-gtk/retro-gl-display.c
@@ -90,11 +90,10 @@ retro_gl_display_get_video_box (RetroGLDisplay *self,
gdouble allocated_ratio;
gint scale;
- g_return_if_fail (RETRO_IS_GL_DISPLAY (self));
- g_return_if_fail (width != NULL);
- g_return_if_fail (height != NULL);
- g_return_if_fail (x != NULL);
- g_return_if_fail (y != NULL);
+ g_assert (width != NULL);
+ g_assert (height != NULL);
+ g_assert (x != NULL);
+ g_assert (y != NULL);
scale = gtk_widget_get_scale_factor (GTK_WIDGET (self));
@@ -280,8 +279,6 @@ retro_gl_display_render (RetroGLDisplay *self)
gint texture_width;
gint texture_height;
- g_return_val_if_fail (RETRO_IS_GL_DISPLAY (self), FALSE);
-
glClear (GL_COLOR_BUFFER_BIT);
filter = self->filter >= RETRO_VIDEO_FILTER_COUNT ?
@@ -372,8 +369,6 @@ retro_gl_display_on_video_output (RetroCore *sender,
{
RetroGLDisplay *self = RETRO_GL_DISPLAY (user_data);
- g_return_if_fail (RETRO_IS_GL_DISPLAY (self));
-
if (pixdata == NULL)
return;
diff --git a/retro-gtk/retro-module-iterator.c b/retro-gtk/retro-module-iterator.c
index 8db068b..30cb96d 100644
--- a/retro-gtk/retro-module-iterator.c
+++ b/retro-gtk/retro-module-iterator.c
@@ -51,8 +51,8 @@ retro_module_iterator_new_for_subdirectory (const gchar *lookup_path,
{
RetroModuleIterator *self;
- g_return_val_if_fail (lookup_path != NULL, NULL);
- g_return_val_if_fail (visited_paths != NULL, NULL);
+ g_assert (lookup_path != NULL);
+ g_assert (visited_paths != NULL);
self = g_object_new (RETRO_TYPE_MODULE_ITERATOR, NULL);
self->directories = g_new0 (gchar *, 2);
@@ -70,8 +70,6 @@ retro_module_iterator_was_current_directory_visited (RetroModuleIterator *self)
gchar *current_directory_path;
gboolean result;
- g_return_val_if_fail (RETRO_IS_MODULE_ITERATOR (self), FALSE);
-
current_directory_file = g_file_new_for_path (self->directories[self->current_directory]);
current_directory_path = g_file_get_path (current_directory_file);
g_object_unref (current_directory_file);
@@ -87,8 +85,6 @@ retro_module_iterator_set_current_directory_as_visited (RetroModuleIterator *sel
GFile *current_directory_file;
gchar *current_directory_path;
- g_return_if_fail (RETRO_IS_MODULE_ITERATOR (self));
-
current_directory_file = g_file_new_for_path (self->directories[self->current_directory]);
current_directory_path = g_file_get_path (current_directory_file);
g_object_unref (current_directory_file);
@@ -98,8 +94,6 @@ retro_module_iterator_set_current_directory_as_visited (RetroModuleIterator *sel
static gboolean
retro_module_iterator_next_in_sub_directory (RetroModuleIterator *self)
{
- g_return_val_if_fail (RETRO_IS_MODULE_ITERATOR (self), FALSE);
-
if (retro_module_iterator_next (self->sub_directory)) {
if (self->core_descriptor != NULL)
g_object_unref (self->core_descriptor);
@@ -132,9 +126,8 @@ retro_module_iterator_iterate_next_in_current_path (RetroModuleIterator *self,
RetroCoreDescriptor *core_descriptor;
GError *tmp_error = NULL;
- g_return_val_if_fail (RETRO_IS_MODULE_ITERATOR (self), FALSE);
- g_return_val_if_fail (G_IS_FILE (directory), FALSE);
- g_return_val_if_fail (G_IS_FILE_INFO (info), FALSE);
+ g_assert (G_IS_FILE (directory));
+ g_assert (G_IS_FILE_INFO (info));
if (self->recursive &&
g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY &&
@@ -190,8 +183,6 @@ retro_module_iterator_next_in_current_path (RetroModuleIterator *self,
GError *tmp_error = NULL;
- g_return_val_if_fail (RETRO_IS_MODULE_ITERATOR (self), FALSE);
-
if (self->sub_directory != NULL &&
retro_module_iterator_next_in_sub_directory (self))
return TRUE;
diff --git a/retro-runner/ipc-runner-impl.c b/retro-runner/ipc-runner-impl.c
index 9ff413b..6c19015 100644
--- a/retro-runner/ipc-runner-impl.c
+++ b/retro-runner/ipc-runner-impl.c
@@ -44,18 +44,13 @@ ipc_runner_impl_handle_boot (IpcRunner *runner,
const gchar * const *medias,
GVariant *default_controller)
{
- IpcRunnerImpl *self;
+ IpcRunnerImpl *self = IPC_RUNNER_IMPL (runner);
g_autoptr(GError) error = NULL;
g_autoptr(GUnixFDList) out_fd_list = NULL;
GVariantIter *iter;
gchar *key, *value;
gint handle, fd;
- g_return_val_if_fail (IPC_IS_RUNNER_IMPL (runner), FALSE);
- g_return_val_if_fail (G_IS_DBUS_METHOD_INVOCATION (invocation), FALSE);
-
- self = IPC_RUNNER_IMPL (runner);
-
g_variant_get (defaults, "a(ss)", &iter);
while (g_variant_iter_loop (iter, "(ss)", &key, &value))
@@ -123,14 +118,9 @@ ipc_runner_impl_handle_set_current_media (IpcRunner *runner,
GDBusMethodInvocation *invocation,
uint index)
{
- IpcRunnerImpl *self;
+ IpcRunnerImpl *self = IPC_RUNNER_IMPL (runner);
g_autoptr(GError) error = NULL;
- g_return_val_if_fail (IPC_IS_RUNNER_IMPL (runner), FALSE);
- g_return_val_if_fail (G_IS_DBUS_METHOD_INVOCATION (invocation), FALSE);
-
- self = IPC_RUNNER_IMPL (runner);
-
retro_core_set_current_media (self->core, index, &error);
if (error) {
g_dbus_method_invocation_return_gerror (g_steal_pointer (&invocation), error);
@@ -147,12 +137,7 @@ static gboolean
ipc_runner_impl_handle_run (IpcRunner *runner,
GDBusMethodInvocation *invocation)
{
- IpcRunnerImpl *self;
-
- g_return_val_if_fail (IPC_IS_RUNNER_IMPL (runner), FALSE);
- g_return_val_if_fail (G_IS_DBUS_METHOD_INVOCATION (invocation), FALSE);
-
- self = IPC_RUNNER_IMPL (runner);
+ IpcRunnerImpl *self = IPC_RUNNER_IMPL (runner);
retro_core_run (self->core);
@@ -165,12 +150,7 @@ static gboolean
ipc_runner_impl_handle_stop (IpcRunner *runner,
GDBusMethodInvocation *invocation)
{
- IpcRunnerImpl *self;
-
- g_return_val_if_fail (IPC_IS_RUNNER_IMPL (runner), FALSE);
- g_return_val_if_fail (G_IS_DBUS_METHOD_INVOCATION (invocation), FALSE);
-
- self = IPC_RUNNER_IMPL (runner);
+ IpcRunnerImpl *self = IPC_RUNNER_IMPL (runner);
retro_core_stop (self->core);
@@ -183,12 +163,7 @@ static gboolean
ipc_runner_impl_handle_reset (IpcRunner *runner,
GDBusMethodInvocation *invocation)
{
- IpcRunnerImpl *self;
-
- g_return_val_if_fail (IPC_IS_RUNNER_IMPL (runner), FALSE);
- g_return_val_if_fail (G_IS_DBUS_METHOD_INVOCATION (invocation), FALSE);
-
- self = IPC_RUNNER_IMPL (runner);
+ IpcRunnerImpl *self = IPC_RUNNER_IMPL (runner);
retro_core_reset (self->core);
@@ -201,12 +176,7 @@ static gboolean
ipc_runner_impl_handle_iteration (IpcRunner *runner,
GDBusMethodInvocation *invocation)
{
- IpcRunnerImpl *self;
-
- g_return_val_if_fail (IPC_IS_RUNNER_IMPL (runner), FALSE);
- g_return_val_if_fail (G_IS_DBUS_METHOD_INVOCATION (invocation), FALSE);
-
- self = IPC_RUNNER_IMPL (runner);
+ IpcRunnerImpl *self = IPC_RUNNER_IMPL (runner);
/* For this call UI process will do the video handling itself
* to ensure it's synchronous, no signal emission needed.
@@ -224,14 +194,9 @@ static gboolean
ipc_runner_impl_handle_get_can_access_state (IpcRunner *runner,
GDBusMethodInvocation *invocation)
{
- IpcRunnerImpl *self;
+ IpcRunnerImpl *self = IPC_RUNNER_IMPL (runner);
gboolean can_access_state;
- g_return_val_if_fail (IPC_IS_RUNNER_IMPL (runner), FALSE);
- g_return_val_if_fail (G_IS_DBUS_METHOD_INVOCATION (invocation), FALSE);
-
- self = IPC_RUNNER_IMPL (runner);
-
can_access_state = retro_core_get_can_access_state (self->core);
ipc_runner_complete_get_can_access_state (runner, invocation, can_access_state);
@@ -244,14 +209,9 @@ ipc_runner_impl_handle_save_state (IpcRunner *runner,
GDBusMethodInvocation *invocation,
const gchar *filename)
{
- IpcRunnerImpl *self;
+ IpcRunnerImpl *self = IPC_RUNNER_IMPL (runner);
g_autoptr(GError) error = NULL;
- g_return_val_if_fail (IPC_IS_RUNNER_IMPL (runner), FALSE);
- g_return_val_if_fail (G_IS_DBUS_METHOD_INVOCATION (invocation), FALSE);
-
- self = IPC_RUNNER_IMPL (runner);
-
retro_core_save_state (self->core, filename, &error);
if (error) {
g_dbus_method_invocation_return_gerror (g_steal_pointer (&invocation), error);
@@ -269,14 +229,9 @@ ipc_runner_impl_handle_load_state (IpcRunner *runner,
GDBusMethodInvocation *invocation,
const gchar *filename)
{
- IpcRunnerImpl *self;
+ IpcRunnerImpl *self = IPC_RUNNER_IMPL (runner);
g_autoptr(GError) error = NULL;
- g_return_val_if_fail (IPC_IS_RUNNER_IMPL (runner), FALSE);
- g_return_val_if_fail (G_IS_DBUS_METHOD_INVOCATION (invocation), FALSE);
-
- self = IPC_RUNNER_IMPL (runner);
-
retro_core_load_state (self->core, filename, &error);
if (error) {
@@ -295,14 +250,9 @@ ipc_runner_impl_handle_get_memory_size (IpcRunner *runner,
GDBusMethodInvocation *invocation,
RetroMemoryType memory_type)
{
- IpcRunnerImpl *self;
+ IpcRunnerImpl *self = IPC_RUNNER_IMPL (runner);
gsize memory_size;
- g_return_val_if_fail (IPC_IS_RUNNER_IMPL (runner), FALSE);
- g_return_val_if_fail (G_IS_DBUS_METHOD_INVOCATION (invocation), FALSE);
-
- self = IPC_RUNNER_IMPL (runner);
-
memory_size = retro_core_get_memory_size (self->core, memory_type);
ipc_runner_complete_get_memory_size (runner, invocation, memory_size);
@@ -316,14 +266,9 @@ ipc_runner_impl_handle_save_memory (IpcRunner *runner,
RetroMemoryType memory_type,
const gchar *filename)
{
- IpcRunnerImpl *self;
+ IpcRunnerImpl *self = IPC_RUNNER_IMPL (runner);
g_autoptr(GError) error = NULL;
- g_return_val_if_fail (IPC_IS_RUNNER_IMPL (runner), FALSE);
- g_return_val_if_fail (G_IS_DBUS_METHOD_INVOCATION (invocation), FALSE);
-
- self = IPC_RUNNER_IMPL (runner);
-
retro_core_save_memory (self->core, memory_type, filename, &error);
if (error) {
@@ -343,14 +288,9 @@ ipc_runner_impl_handle_load_memory (IpcRunner *runner,
RetroMemoryType memory_type,
const gchar *filename)
{
- IpcRunnerImpl *self;
+ IpcRunnerImpl *self = IPC_RUNNER_IMPL (runner);
g_autoptr(GError) error = NULL;
- g_return_val_if_fail (IPC_IS_RUNNER_IMPL (runner), FALSE);
- g_return_val_if_fail (G_IS_DBUS_METHOD_INVOCATION (invocation), FALSE);
-
- self = IPC_RUNNER_IMPL (runner);
-
retro_core_load_memory (self->core, memory_type, filename, &error);
if (error) {
@@ -370,12 +310,7 @@ ipc_runner_impl_handle_update_variable (IpcRunner *runner,
const gchar *key,
const gchar *value)
{
- IpcRunnerImpl *self;
-
- g_return_val_if_fail (IPC_IS_RUNNER_IMPL (runner), FALSE);
- g_return_val_if_fail (G_IS_DBUS_METHOD_INVOCATION (invocation), FALSE);
-
- self = IPC_RUNNER_IMPL (runner);
+ IpcRunnerImpl *self = IPC_RUNNER_IMPL (runner);
retro_core_update_variable (self->core, key, value);
@@ -392,14 +327,9 @@ ipc_runner_handle_set_controller (IpcRunner *runner,
RetroControllerType type,
GVariant *data_handle)
{
- IpcRunnerImpl *self;
+ IpcRunnerImpl *self = IPC_RUNNER_IMPL (runner);
gint fd;
- g_return_val_if_fail (IPC_IS_RUNNER_IMPL (runner), FALSE);
- g_return_val_if_fail (G_IS_DBUS_METHOD_INVOCATION (invocation), FALSE);
-
- self = IPC_RUNNER_IMPL (runner);
-
if (type != RETRO_CONTROLLER_TYPE_NONE) {
g_autoptr(GError) error = NULL;
gint handle;
@@ -439,12 +369,7 @@ ipc_runner_impl_handle_key_event (IpcRunner *runner,
guint32 character,
RetroKeyboardModifierKey modifiers)
{
- IpcRunnerImpl *self;
-
- g_return_val_if_fail (IPC_IS_RUNNER_IMPL (runner), FALSE);
- g_return_val_if_fail (G_IS_DBUS_METHOD_INVOCATION (invocation), FALSE);
-
- self = IPC_RUNNER_IMPL (runner);
+ IpcRunnerImpl *self = IPC_RUNNER_IMPL (runner);
retro_core_send_input_key_event (self->core, pressed, keycode, character, modifiers);
@@ -457,12 +382,7 @@ static gboolean
ipc_runner_impl_handle_get_properties (IpcRunner *runner,
GDBusMethodInvocation *invocation)
{
- IpcRunnerImpl *self;
-
- g_return_val_if_fail (IPC_IS_RUNNER_IMPL (runner), FALSE);
- g_return_val_if_fail (G_IS_DBUS_METHOD_INVOCATION (invocation), FALSE);
-
- self = IPC_RUNNER_IMPL (runner);
+ IpcRunnerImpl *self = IPC_RUNNER_IMPL (runner);
ipc_runner_complete_get_properties (runner, invocation,
retro_core_get_game_loaded (self->core),
diff --git a/retro-runner/retro-core.c b/retro-runner/retro-core.c
index c65c452..194caec 100644
--- a/retro-runner/retro-core.c
+++ b/retro-runner/retro-core.c
@@ -107,8 +107,6 @@ retro_core_finalize (GObject *object)
RetroUnloadGame unload_game;
RetroDeinit deinit;
- g_return_if_fail (RETRO_IS_CORE (self));
-
retro_core_stop (self);
if (retro_core_get_game_loaded (self)) {
@@ -587,8 +585,6 @@ static void
retro_core_set_filename (RetroCore *self,
const gchar *filename)
{
- g_return_if_fail (RETRO_IS_CORE (self));
-
if (g_strcmp0 (filename, retro_core_get_filename (self)) == 0)
return;
@@ -601,8 +597,6 @@ static void
retro_core_set_is_initiated (RetroCore *self,
gboolean is_initiated)
{
- g_return_if_fail (RETRO_IS_CORE (self));
-
if (retro_core_get_is_initiated (self) == is_initiated)
return;
@@ -614,8 +608,6 @@ static void
retro_core_set_game_loaded (RetroCore *self,
gboolean game_loaded)
{
- g_return_if_fail (RETRO_IS_CORE (self));
-
if (retro_core_get_game_loaded (self) == game_loaded)
return;
@@ -636,8 +628,7 @@ retro_core_get_system_info (RetroCore *self,
{
RetroGetSystemInfo get_system_info;
- g_return_if_fail (RETRO_IS_CORE (self));
- g_return_if_fail (system_info != NULL);
+ g_assert (system_info != NULL);
get_system_info = retro_module_get_get_system_info (self->module);
get_system_info (system_info);
@@ -710,9 +701,8 @@ retro_core_update_variable (RetroCore *self,
const gchar *key,
const gchar *value)
{
- g_return_if_fail (RETRO_IS_CORE (self));
- g_return_if_fail (key != NULL);
- g_return_if_fail (value != NULL);
+ g_assert (key != NULL);
+ g_assert (value != NULL);
g_hash_table_replace (self->variables, g_strdup (key), g_strdup (value));
@@ -726,8 +716,6 @@ retro_core_set_disk_ejected (RetroCore *self,
{
RetroDiskControlCallbackSetEjectState set_eject_state;
- g_return_val_if_fail (RETRO_IS_CORE (self), FALSE);
-
set_eject_state = self->disk_control_callback->set_eject_state;
if (set_eject_state == NULL) {
@@ -749,8 +737,6 @@ retro_core_set_disk_image_index (RetroCore *self,
{
RetroDiskControlCallbackSetImageIndex set_image_index;
- g_return_val_if_fail (RETRO_IS_CORE (self), FALSE);
-
set_image_index = self->disk_control_callback->set_image_index;
if (set_image_index == NULL) {
@@ -771,8 +757,6 @@ retro_core_get_disk_images_number (RetroCore *self,
{
RetroDiskControlCallbackGetNumImages get_num_images;
- g_return_val_if_fail (RETRO_IS_CORE (self), FALSE);
-
get_num_images = self->disk_control_callback->get_num_images;
if (get_num_images == NULL) {
@@ -795,8 +779,6 @@ retro_core_replace_disk_image_index (RetroCore *self,
{
RetroDiskControlCallbackReplaceImageIndex replace_image_index;
- g_return_val_if_fail (RETRO_IS_CORE (self), FALSE);
-
replace_image_index = self->disk_control_callback->replace_image_index;
if (replace_image_index == NULL) {
@@ -817,8 +799,6 @@ retro_core_add_disk_image_index (RetroCore *self,
{
RetroDiskControlCallbackAddImageIndex add_image_index;
- g_return_val_if_fail (RETRO_IS_CORE (self), FALSE);
-
add_image_index = self->disk_control_callback->add_image_index;
if (add_image_index == NULL) {
@@ -845,8 +825,6 @@ retro_core_load_discs (RetroCore *self,
RetroGameInfo *game_info = NULL;
GError *tmp_error = NULL;
- g_return_if_fail (RETRO_IS_CORE (self));
-
retro_core_set_disk_ejected (self, TRUE, &tmp_error);
if (G_UNLIKELY (tmp_error != NULL)) {
g_propagate_error (error, tmp_error);
@@ -927,8 +905,7 @@ retro_core_load_game (RetroCore *self,
gboolean game_loaded;
RetroSystemAvInfo info = {{ 0 }};
- g_return_val_if_fail (RETRO_IS_CORE (self), FALSE);
- g_return_val_if_fail (game != NULL, FALSE);
+ g_assert (game != NULL);
if (retro_core_get_game_loaded (self)) {
unload_game = retro_module_get_unload_game (self->module);
@@ -952,8 +929,6 @@ retro_core_prepare (RetroCore *self) {
gboolean game_loaded;
RetroSystemAvInfo info = {{ 0 }};
- g_return_val_if_fail (RETRO_IS_CORE (self), FALSE);
-
load_game = retro_module_get_load_game (self->module);
game_loaded = load_game (NULL);
retro_core_set_game_loaded (self, game_loaded);
@@ -976,7 +951,6 @@ retro_core_load_medias (RetroCore *self,
RetroGameInfo *game_info = NULL;
GError *tmp_error = NULL;
- g_return_if_fail (RETRO_IS_CORE (self));
length = self->media_uris == NULL ? 0 : g_strv_length (self->media_uris);
if (length == 0) {
diff --git a/retro-runner/retro-module.c b/retro-runner/retro-module.c
index cc4d28e..9bb4546 100644
--- a/retro-runner/retro-module.c
+++ b/retro-runner/retro-module.c
@@ -52,7 +52,7 @@ try_delete_file (GFile *file)
{
GError *inner_error = NULL;
- g_return_if_fail (file != NULL);
+ g_assert (file != NULL);
g_file_delete (file, NULL, &inner_error);
if (G_UNLIKELY (inner_error != NULL)) {
diff --git a/retro-runner/retro-pa-player.c b/retro-runner/retro-pa-player.c
index 9dcde9b..eed793b 100644
--- a/retro-runner/retro-pa-player.c
+++ b/retro-runner/retro-pa-player.c
@@ -70,8 +70,6 @@ retro_pa_player_prepare_for_sample_rate (RetroPaPlayer *self,
pa_sample_spec sample_spec = {0};
gint error;
- g_return_if_fail (RETRO_IS_PA_PLAYER (self));
-
self->sample_rate = sample_rate;
pa_sample_spec_init (&sample_spec);
diff --git a/tests/retro-reftest.c b/tests/retro-reftest.c
index e099e76..2ab604b 100644
--- a/tests/retro-reftest.c
+++ b/tests/retro-reftest.c
@@ -62,8 +62,6 @@ static const GOptionEntry test_args[] = {
static RetroReftestData *
retro_reftest_data_ref (RetroReftestData *self) {
- g_return_val_if_fail (self != NULL, NULL);
-
self->refs++;
return self;
@@ -71,8 +69,6 @@ retro_reftest_data_ref (RetroReftestData *self) {
static void
retro_reftest_data_unref (RetroReftestData *self) {
- g_return_if_fail (self != NULL);
-
if (self->refs == 0) {
g_object_unref (self->core);
retro_pixdata_free (self->pixdata);
@@ -88,8 +84,6 @@ retro_reftest_data_unref (RetroReftestData *self) {
static void
retro_reftest_options_unref (RetroReftestOptions *self) {
- g_return_if_fail (self != NULL);
-
if (self->refs == 0) {
retro_reftest_data_unref (self->data);
g_hash_table_unref (self->options);
@@ -103,8 +97,6 @@ retro_reftest_options_unref (RetroReftestOptions *self) {
static void
retro_reftest_run_unref (RetroReftestRun *self) {
- g_return_if_fail (self != NULL);
-
if (self->refs == 0) {
retro_reftest_data_unref (self->data);
if (self->controller_states != NULL)
@@ -119,8 +111,6 @@ retro_reftest_run_unref (RetroReftestRun *self) {
static void
retro_reftest_video_unref (RetroReftestVideo *self) {
- g_return_if_fail (self != NULL);
-
if (self->refs == 0) {
retro_reftest_data_unref (self->data);
g_object_unref (self->video_file);
diff --git a/tests/retro-test-controller.c b/tests/retro-test-controller.c
index 7c8df6f..a7713ac 100644
--- a/tests/retro-test-controller.c
+++ b/tests/retro-test-controller.c
@@ -45,8 +45,6 @@ retro_test_controller_get_input_state (RetroController *base,
{
RetroTestController *self = RETRO_TEST_CONTROLLER (base);
- g_return_val_if_fail (self != NULL, 0);
-
switch (retro_input_get_controller_type (input) & RETRO_CONTROLLER_TYPE_TYPE_MASK) {
case RETRO_CONTROLLER_TYPE_JOYPAD: {
RetroJoypadId id;
@@ -97,8 +95,6 @@ retro_test_controller_get_controller_type (RetroController *base)
{
RetroTestController *self = RETRO_TEST_CONTROLLER (base);
- g_return_val_if_fail (self != NULL, 0);
-
return self->controller_type;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]