gio: Use g_task_return_error_literal() where we don't need formatting

This commit is contained in:
Marco Trevisan (Treviño) 2023-12-19 21:03:28 +01:00 committed by Philip Withnall
parent 7c71090723
commit 81068e5c00
15 changed files with 71 additions and 61 deletions

View File

@ -721,8 +721,8 @@ g_app_info_launch_uris_async (GAppInfo *appinfo,
task = g_task_new (appinfo, cancellable, callback, user_data);
g_task_set_source_tag (task, g_app_info_launch_uris_async);
g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
"Operation not supported for the current backend.");
g_task_return_new_error_literal (task, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
"Operation not supported for the current backend.");
g_object_unref (task);
return;

View File

@ -1828,7 +1828,7 @@ send_message_data_deliver_error (GTask *task,
send_message_with_reply_cleanup (task, TRUE);
CONNECTION_UNLOCK (connection);
g_task_return_new_error (task, domain, code, "%s", message);
g_task_return_new_error_literal (task, domain, code, message);
g_object_unref (task);
}
@ -2386,10 +2386,10 @@ cancel_method_on_close (gpointer key, gpointer value, gpointer user_data)
if (data->delivered)
return FALSE;
g_task_return_new_error (task,
G_IO_ERROR,
G_IO_ERROR_CLOSED,
_("The connection is closed"));
g_task_return_new_error_literal (task,
G_IO_ERROR,
G_IO_ERROR_CLOSED,
_("The connection is closed"));
/* Ask send_message_with_reply_cleanup not to remove the element from the
* hash table - we're in the middle of a foreach; that would be unsafe.

View File

@ -1030,10 +1030,12 @@ write_message_continue_writing (MessageToWriteData *data)
if (!(data->worker->capabilities & G_DBUS_CAPABILITY_FLAGS_UNIX_FD_PASSING))
{
GTask *task = g_steal_pointer (&data->task);
g_task_return_new_error (task,
G_IO_ERROR,
G_IO_ERROR_FAILED,
"Tried sending a file descriptor but remote peer does not support this capability");
g_task_return_new_error_literal (task,
G_IO_ERROR,
G_IO_ERROR_FAILED,
"Tried sending a file descriptor "
"but remote peer does not support "
"this capability");
g_clear_object (&task);
goto out;
}

View File

@ -7721,9 +7721,9 @@ query_default_handler_query_app_info_for_type_cb (GObject *object,
}
else if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
{
g_task_return_new_error (task,
G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
"%s", error->message);
g_task_return_new_error_literal (task,
G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
error->message);
}
else
{
@ -7774,10 +7774,10 @@ query_default_handler_query_info_cb (GObject *object,
}
else
{
g_task_return_new_error (task,
G_IO_ERROR,
G_IO_ERROR_NOT_SUPPORTED,
_("No application is registered as handling this file"));
g_task_return_new_error_literal (task,
G_IO_ERROR,
G_IO_ERROR_NOT_SUPPORTED,
_("No application is registered as handling this file"));
}
g_object_unref (info);

View File

@ -285,8 +285,9 @@ can_reach_async_got_address (GObject *object,
else
{
/* Resolved all addresses, none matched */
g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_HOST_UNREACHABLE,
_("Host unreachable"));
g_task_return_new_error_literal (task, G_IO_ERROR,
G_IO_ERROR_HOST_UNREACHABLE,
_("Host unreachable"));
g_object_unref (task);
return;
}
@ -321,8 +322,8 @@ g_network_monitor_base_can_reach_async (GNetworkMonitor *monitor,
if (g_hash_table_size (G_NETWORK_MONITOR_BASE (monitor)->priv->networks) == 0)
{
g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_NETWORK_UNREACHABLE,
_("Network unreachable"));
g_task_return_new_error_literal (task, G_IO_ERROR, G_IO_ERROR_NETWORK_UNREACHABLE,
_("Network unreachable"));
g_object_unref (task);
return;
}

View File

@ -561,9 +561,9 @@ can_reach_done (GObject *source,
if (reachable)
g_task_return_boolean (task, TRUE);
else
g_task_return_new_error (task,
G_IO_ERROR, G_IO_ERROR_HOST_UNREACHABLE,
"Can't reach host");
g_task_return_new_error_literal (task,
G_IO_ERROR, G_IO_ERROR_HOST_UNREACHABLE,
"Can't reach host");
g_object_unref (task);
}

View File

@ -182,11 +182,11 @@ response_received (GDBusConnection *connection,
g_task_return_boolean (task, TRUE);
break;
case XDG_DESKTOP_PORTAL_CANCELLED:
g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_CANCELLED, "Launch cancelled");
g_task_return_new_error_literal (task, G_IO_ERROR, G_IO_ERROR_CANCELLED, "Launch cancelled");
break;
case XDG_DESKTOP_PORTAL_FAILED:
default:
g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_FAILED, "Launch failed");
g_task_return_new_error_literal (task, G_IO_ERROR, G_IO_ERROR_FAILED, "Launch failed");
break;
}

View File

@ -1764,9 +1764,9 @@ g_output_stream_splice_async (GOutputStream *stream,
if (g_input_stream_is_closed (source))
{
g_task_return_new_error (task,
G_IO_ERROR, G_IO_ERROR_CLOSED,
_("Source stream is already closed"));
g_task_return_new_error_literal (task,
G_IO_ERROR, G_IO_ERROR_CLOSED,
_("Source stream is already closed"));
g_object_unref (task);
return;
}

View File

@ -343,9 +343,14 @@ complete_async (GTask *task)
priv->last_error = NULL;
}
else if (!priv->ever_enumerated)
g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_FAILED, _("Unspecified proxy lookup failure"));
{
g_task_return_new_error_literal (task, G_IO_ERROR, G_IO_ERROR_FAILED,
_("Unspecified proxy lookup failure"));
}
else
g_task_return_pointer (task, NULL, NULL);
{
g_task_return_pointer (task, NULL, NULL);
}
priv->ever_enumerated = TRUE;

View File

@ -724,10 +724,10 @@ nego_reply_read_cb (GObject *source,
if (read == 0)
{
g_task_return_new_error (task,
G_IO_ERROR,
G_IO_ERROR_CONNECTION_CLOSED,
"Connection to SOCKSv5 proxy server lost");
g_task_return_new_error_literal (task,
G_IO_ERROR,
G_IO_ERROR_CONNECTION_CLOSED,
"Connection to SOCKSv5 proxy server lost");
g_object_unref (task);
return;
}
@ -837,10 +837,10 @@ auth_reply_read_cb (GObject *source,
if (read == 0)
{
g_task_return_new_error (task,
G_IO_ERROR,
G_IO_ERROR_CONNECTION_CLOSED,
"Connection to SOCKSv5 proxy server lost");
g_task_return_new_error_literal (task,
G_IO_ERROR,
G_IO_ERROR_CONNECTION_CLOSED,
"Connection to SOCKSv5 proxy server lost");
g_object_unref (task);
return;
}
@ -949,10 +949,10 @@ connect_reply_read_cb (GObject *source,
if (read == 0)
{
g_task_return_new_error (task,
G_IO_ERROR,
G_IO_ERROR_CONNECTION_CLOSED,
"Connection to SOCKSv5 proxy server lost");
g_task_return_new_error_literal (task,
G_IO_ERROR,
G_IO_ERROR_CONNECTION_CLOSED,
"Connection to SOCKSv5 proxy server lost");
g_object_unref (task);
return;
}
@ -1019,10 +1019,10 @@ connect_addr_len_read_cb (GObject *source,
if (read == 0)
{
g_task_return_new_error (task,
G_IO_ERROR,
G_IO_ERROR_CONNECTION_CLOSED,
"Connection to SOCKSv5 proxy server lost");
g_task_return_new_error_literal (task,
G_IO_ERROR,
G_IO_ERROR_CONNECTION_CLOSED,
"Connection to SOCKSv5 proxy server lost");
g_object_unref (task);
return;
}
@ -1055,10 +1055,10 @@ connect_addr_read_cb (GObject *source,
if (read == 0)
{
g_task_return_new_error (task,
G_IO_ERROR,
G_IO_ERROR_CONNECTION_CLOSED,
"Connection to SOCKSv5 proxy server lost");
g_task_return_new_error_literal (task,
G_IO_ERROR,
G_IO_ERROR_CONNECTION_CLOSED,
"Connection to SOCKSv5 proxy server lost");
g_object_unref (task);
return;
}

View File

@ -1448,8 +1448,10 @@ timeout_cb (gpointer user_data)
g_mutex_unlock (&data->lock);
if (should_return)
g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_TIMED_OUT,
_("Socket I/O timed out"));
{
g_task_return_new_error_literal (task, G_IO_ERROR, G_IO_ERROR_TIMED_OUT,
_("Socket I/O timed out"));
}
/* Signal completion of the task. */
g_mutex_lock (&data->lock);

View File

@ -262,7 +262,7 @@ eject_unmount_done (GObject *source,
{
if (!g_subprocess_get_successful (subprocess))
/* ...but bad exit code */
g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_FAILED, "%s", stderr_str);
g_task_return_new_error_literal (task, G_IO_ERROR, G_IO_ERROR_FAILED, stderr_str);
else
/* ...and successful exit code */
g_task_return_boolean (task, TRUE);

View File

@ -287,7 +287,7 @@ eject_mount_done (GObject *source,
{
if (!g_subprocess_get_successful (subprocess))
/* ...but bad exit code */
g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_FAILED, "%s", stderr_str);
g_task_return_new_error_literal (task, G_IO_ERROR, G_IO_ERROR_FAILED, stderr_str);
else
{
/* ...and successful exit code */

View File

@ -797,9 +797,9 @@ g_fake_resolver_lookup_by_name_async (GResolver *resolver,
}
else
{
g_task_return_new_error (task,
G_RESOLVER_ERROR, G_RESOLVER_ERROR_NOT_FOUND,
"Not found");
g_task_return_new_error_literal (task,
G_RESOLVER_ERROR, G_RESOLVER_ERROR_NOT_FOUND,
"Not found");
}
g_object_unref (task);
}

View File

@ -149,7 +149,7 @@ test_interaction_ask_password_async_failure (GTlsInteraction *interaction,
task = g_task_new (self, cancellable, callback, user_data);
g_task_return_new_error (task, G_FILE_ERROR, G_FILE_ERROR_ACCES, "The message");
g_task_return_new_error_literal (task, G_FILE_ERROR, G_FILE_ERROR_ACCES, "The message");
g_object_unref (task);
}
@ -348,7 +348,7 @@ test_interaction_request_certificate_async_failure (GTlsInteraction *interact
task = g_task_new (self, cancellable, callback, user_data);
g_task_return_new_error (task, G_FILE_ERROR, G_FILE_ERROR_NOENT, "Another message");
g_task_return_new_error_literal (task, G_FILE_ERROR, G_FILE_ERROR_NOENT, "Another message");
g_object_unref (task);
}