Skip to content

Commit

Permalink
Merge pull request #948 from tbzatek/part-error-ownership
Browse files Browse the repository at this point in the history
Fix GError ownerships
  • Loading branch information
tbzatek authored Jan 2, 2022
2 parents 91dfe57 + 2232567 commit 851996d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 22 deletions.
3 changes: 1 addition & 2 deletions src/udiskslinuxencrypted.c
Original file line number Diff line number Diff line change
Expand Up @@ -1040,7 +1040,7 @@ handle_resize (UDisksEncrypted *encrypted,
object = udisks_daemon_util_dup_object (encrypted, &error);
if (object == NULL)
{
g_dbus_method_invocation_take_error (invocation, error);
g_dbus_method_invocation_return_gerror (invocation, error);
goto out;
}

Expand All @@ -1066,7 +1066,6 @@ handle_resize (UDisksEncrypted *encrypted,
if (!udisks_daemon_util_get_caller_uid_sync (daemon, invocation, NULL /* GCancellable */, &caller_uid, &error))
{
g_dbus_method_invocation_return_gerror (invocation, error);
g_clear_error (&error);
goto out;
}

Expand Down
8 changes: 4 additions & 4 deletions src/udiskslinuxfilesystem.c
Original file line number Diff line number Diff line change
Expand Up @@ -1739,7 +1739,7 @@ handle_resize (UDisksFilesystem *filesystem,
object = udisks_daemon_util_dup_object (filesystem, &error);
if (object == NULL)
{
g_dbus_method_invocation_take_error (invocation, error);
g_dbus_method_invocation_return_gerror (invocation, error);
goto out;
}

Expand Down Expand Up @@ -1921,7 +1921,7 @@ handle_repair (UDisksFilesystem *filesystem,
object = udisks_daemon_util_dup_object (filesystem, &error);
if (object == NULL)
{
g_dbus_method_invocation_take_error (invocation, error);
g_dbus_method_invocation_return_gerror (invocation, error);
goto out;
}

Expand Down Expand Up @@ -2089,7 +2089,7 @@ handle_check (UDisksFilesystem *filesystem,
object = udisks_daemon_util_dup_object (filesystem, &error);
if (object == NULL)
{
g_dbus_method_invocation_take_error (invocation, error);
g_dbus_method_invocation_return_gerror (invocation, error);
goto out;
}

Expand Down Expand Up @@ -2257,7 +2257,7 @@ handle_take_ownership (UDisksFilesystem *filesystem,
object = udisks_daemon_util_dup_object (filesystem, &error);
if (object == NULL)
{
g_dbus_method_invocation_take_error (invocation, error);
g_dbus_method_invocation_return_gerror (invocation, error);
goto out;
}

Expand Down
15 changes: 6 additions & 9 deletions src/udiskslinuxpartition.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,7 @@ check_authorization (UDisksPartition *partition,
caller_uid,
&error))
{
g_dbus_method_invocation_return_gerror (invocation, error);
g_clear_error (&error);
g_dbus_method_invocation_take_error (invocation, error);
goto out;
}

Expand Down Expand Up @@ -351,7 +350,7 @@ handle_set_flags (UDisksPartition *partition,
object = udisks_daemon_util_dup_object (partition, &error);
if (object == NULL)
{
g_dbus_method_invocation_take_error (invocation, error);
g_dbus_method_invocation_return_gerror (invocation, error);
goto out;
}

Expand Down Expand Up @@ -499,7 +498,7 @@ handle_set_name (UDisksPartition *partition,
object = udisks_daemon_util_dup_object (partition, &error);
if (object == NULL)
{
g_dbus_method_invocation_take_error (invocation, error);
g_dbus_method_invocation_return_gerror (invocation, error);
goto out;
}

Expand Down Expand Up @@ -873,7 +872,7 @@ handle_resize (UDisksPartition *partition,
object = udisks_daemon_util_dup_object (partition, &error);
if (object == NULL)
{
g_dbus_method_invocation_take_error (invocation, error);
g_dbus_method_invocation_return_gerror (invocation, error);
goto out;
}

Expand Down Expand Up @@ -994,7 +993,7 @@ handle_delete (UDisksPartition *partition,
object = udisks_daemon_util_dup_object (partition, &error);
if (object == NULL)
{
g_dbus_method_invocation_take_error (invocation, error);
g_dbus_method_invocation_return_gerror (invocation, error);
goto out;
}

Expand All @@ -1012,9 +1011,7 @@ handle_delete (UDisksPartition *partition,
if (!udisks_linux_block_teardown (block, invocation, options, &error))
{
if (invocation != NULL)
g_dbus_method_invocation_take_error (invocation, error);
else
g_clear_error (&error);
g_dbus_method_invocation_return_gerror (invocation, error);
goto out;
}
}
Expand Down
11 changes: 4 additions & 7 deletions src/udiskslinuxpartitiontable.c
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ udisks_linux_partition_table_handle_create_partition (UDisksPartitionTable *ta
object = udisks_daemon_util_dup_object (table, &error);
if (object == NULL)
{
g_dbus_method_invocation_take_error (invocation, error);
g_dbus_method_invocation_return_gerror (invocation, error);
goto out;
}

Expand All @@ -293,15 +293,13 @@ udisks_linux_partition_table_handle_create_partition (UDisksPartitionTable *ta
goto out;
}

error = NULL;
if (!udisks_daemon_util_get_caller_uid_sync (daemon,
invocation,
NULL /* GCancellable */,
&caller_uid,
&error))
{
g_dbus_method_invocation_return_gerror (invocation, error);
g_clear_error (&error);
goto out;
}

Expand Down Expand Up @@ -464,7 +462,7 @@ udisks_linux_partition_table_handle_create_partition (UDisksPartitionTable *ta
if (!bd_part_set_part_name (device_name, part_spec->path, name, &error))
{
g_prefix_error (&error, "Error setting name for newly created partition: ");
g_dbus_method_invocation_take_error (invocation, error);
g_dbus_method_invocation_return_gerror (invocation, error);
udisks_simple_job_complete (UDISKS_SIMPLE_JOB (job), FALSE, error->message);
goto out;
}
Expand All @@ -483,7 +481,7 @@ udisks_linux_partition_table_handle_create_partition (UDisksPartitionTable *ta
if (!ret)
{
g_prefix_error (&error, "Error setting type for newly created partition: ");
g_dbus_method_invocation_take_error (invocation, error);
g_dbus_method_invocation_return_gerror (invocation, error);
udisks_simple_job_complete (UDISKS_SIMPLE_JOB (job), FALSE, error->message);
goto out;
}
Expand Down Expand Up @@ -520,7 +518,6 @@ udisks_linux_partition_table_handle_create_partition (UDisksPartitionTable *ta
/* sit and wait for the partition to show up */
g_warn_if_fail (wait_data->pos_to_wait_for > 0);
wait_data->partition_table_object = object;
error = NULL;
partition_object = udisks_daemon_wait_for_object_sync (daemon,
wait_for_partition,
wait_data,
Expand All @@ -530,7 +527,7 @@ udisks_linux_partition_table_handle_create_partition (UDisksPartitionTable *ta
if (partition_object == NULL)
{
g_prefix_error (&error, "Error waiting for partition to appear: ");
g_dbus_method_invocation_take_error (invocation, error);
g_dbus_method_invocation_return_gerror (invocation, error);
udisks_simple_job_complete (UDISKS_SIMPLE_JOB (job), FALSE, error->message);
goto out;
}
Expand Down

0 comments on commit 851996d

Please sign in to comment.