Do not use GError to just return an error string

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
This commit is contained in:
Frediano Ziglio 2020-02-06 21:38:51 +00:00 committed by Frediano Ziglio
parent 4233df686e
commit 2b11c917dc
4 changed files with 15 additions and 36 deletions

View File

@ -796,22 +796,18 @@ static void mini_header_set_msg_sub_list(SpiceDataHeaderOpaque *header, uint32_t
bool RedChannelClient::init()
{
GError *local_error = NULL;
char *local_error = NULL;
SpiceCoreInterfaceInternal *core;
if (!priv->stream) {
g_set_error_literal(&local_error,
SPICE_SERVER_ERROR,
SPICE_SERVER_ERROR_FAILED,
"Socket not available");
local_error =
g_strdup_printf("Socket not available");
goto cleanup;
}
if (!config_socket()) {
g_set_error_literal(&local_error,
SPICE_SERVER_ERROR,
SPICE_SERVER_ERROR_FAILED,
"Unable to configure socket");
local_error =
g_strdup_printf("Unable to configure socket");
goto cleanup;
}
@ -844,8 +840,8 @@ cleanup:
if (local_error) {
red_channel_warning(get_channel(),
"Failed to create channel client: %s",
local_error->message);
g_error_free(local_error);
local_error);
g_free(local_error);
}
return local_error == NULL;
}
@ -1689,8 +1685,3 @@ bool RedChannelClient::set_migration_seamless()
return ret;
}
GQuark spice_server_error_quark(void)
{
return g_quark_from_static_string("spice-server-error-quark");
}

View File

@ -203,14 +203,6 @@ private:
red::unique_link<RedChannelClientPrivate> priv;
};
#define SPICE_SERVER_ERROR spice_server_error_quark()
GQuark spice_server_error_quark(void);
typedef enum
{
SPICE_SERVER_ERROR_FAILED
} SpiceServerError;
/* Messages handled by RedChannel
* SET_ACK - sent to client on channel connection
* Note that the numbers don't have to correspond to spice message types,

View File

@ -152,7 +152,7 @@ RedChannelClient *RedClient::get_channel(int type, int id)
return NULL;
}
gboolean RedClient::add_channel(RedChannelClient *rcc, GError **error)
gboolean RedClient::add_channel(RedChannelClient *rcc, char **error)
{
RedChannel *channel;
gboolean result = TRUE;
@ -165,21 +165,17 @@ gboolean RedClient::add_channel(RedChannelClient *rcc, GError **error)
uint32_t type = channel->type();
uint32_t id = channel->id();
if (disconnecting) {
g_set_error(error,
SPICE_SERVER_ERROR,
SPICE_SERVER_ERROR_FAILED,
"Client %p got disconnected while connecting channel type %d id %d",
this, type, id);
*error =
g_strdup_printf("Client %p got disconnected while connecting channel type %d id %d",
this, type, id);
result = FALSE;
goto cleanup;
}
if (get_channel(type, id)) {
g_set_error(error,
SPICE_SERVER_ERROR,
SPICE_SERVER_ERROR_FAILED,
"Client %p: duplicate channel type %d id %d",
this, type, id);
*error =
g_strdup_printf("Client %p: duplicate channel type %d id %d",
this, type, id);
result = FALSE;
goto cleanup;
}

View File

@ -43,7 +43,7 @@ public:
*/
void destroy();
gboolean add_channel(RedChannelClient *rcc, GError **error);
gboolean add_channel(RedChannelClient *rcc, char **error);
static void remove_channel(RedChannelClient *rcc);
MainChannelClient *get_main();