Wed, 02 Oct 2019 19:56:45 -0400
Don't pass literals to g_set_error / g_error_new.
--- a/libpurple/keyring.c Wed Oct 02 19:25:51 2019 -0400 +++ b/libpurple/keyring.c Wed Oct 02 19:56:45 2019 -0400 @@ -240,9 +240,9 @@ current_change_tracker = NULL; if (tracker->error == NULL) { - tracker->error = g_error_new(PURPLE_KEYRING_ERROR, - PURPLE_KEYRING_ERROR_UNKNOWN, - _("An unknown error has occured.")); + tracker->error = g_error_new_literal( + PURPLE_KEYRING_ERROR, PURPLE_KEYRING_ERROR_UNKNOWN, + _("An unknown error has occured.")); } if (tracker->cb != NULL) @@ -379,10 +379,10 @@ "session already running.\n"); if (cb == NULL) return; - error = g_error_new(PURPLE_KEYRING_ERROR, - PURPLE_KEYRING_ERROR_INTERNAL, - _("There is a password migration session already " - "running.")); + error = g_error_new_literal( + PURPLE_KEYRING_ERROR, PURPLE_KEYRING_ERROR_INTERNAL, + _("There is a password migration session already " + "running.")); cb(error, data); g_error_free(error); return; @@ -681,11 +681,9 @@ keyring = purple_keyring_find_keyring_by_id(keyring_id); if (keyring == NULL) { - if (error != NULL) { - *error = g_error_new(PURPLE_KEYRING_ERROR, - PURPLE_KEYRING_ERROR_BACKENDFAIL, - _("Specified keyring is not registered.")); - } + g_set_error_literal(error, PURPLE_KEYRING_ERROR, + PURPLE_KEYRING_ERROR_BACKENDFAIL, + _("Specified keyring is not registered.")); purple_debug_warning("Keyring", "Specified keyring is not " "registered, cannot import password info for account " "%s.\n", purple_keyring_print_account(account)); @@ -695,12 +693,9 @@ inuse = purple_keyring_get_inuse(); if (inuse == NULL) { PurpleKeyringFailedImport *import; - if (error != NULL) { - *error = g_error_new(PURPLE_KEYRING_ERROR, - PURPLE_KEYRING_ERROR_NOKEYRING, - _("No keyring loaded, cannot import password " - "info.")); - } + g_set_error_literal( + error, PURPLE_KEYRING_ERROR, PURPLE_KEYRING_ERROR_NOKEYRING, + _("No keyring loaded, cannot import password info.")); purple_debug_warning("Keyring", "No keyring loaded, cannot import password info for " "account %s.\n", purple_keyring_print_account(account)); @@ -715,12 +710,9 @@ } if (inuse != keyring) { - if (error != NULL) { - *error = g_error_new(PURPLE_KEYRING_ERROR, - PURPLE_KEYRING_ERROR_INTERNAL, - _("Specified keyring ID does not match the " - "loaded one.")); - } + g_set_error_literal( + error, PURPLE_KEYRING_ERROR, PURPLE_KEYRING_ERROR_INTERNAL, + _("Specified keyring ID does not match the loaded one.")); purple_debug_error("keyring", "Specified keyring %s is not currently used (%s). " "Data will be lost.\n", keyring_id, @@ -762,10 +754,9 @@ purple_keyring_failed_imports, account); if (import == NULL) { - *error = g_error_new(PURPLE_KEYRING_ERROR, - PURPLE_KEYRING_ERROR_NOKEYRING, - _("No keyring configured, cannot export " - "password info.")); + g_set_error_literal( + error, PURPLE_KEYRING_ERROR, PURPLE_KEYRING_ERROR_NOKEYRING, + _("No keyring configured, cannot export password info.")); purple_debug_warning("keyring", "No keyring configured, cannot export password " "info.\n"); @@ -823,9 +814,9 @@ "quitting.\n"); if (cb == NULL) return; - error = g_error_new(PURPLE_KEYRING_ERROR, - PURPLE_KEYRING_ERROR_INTERNAL, - _("Cannot request a password while quitting.")); + error = g_error_new_literal( + PURPLE_KEYRING_ERROR, PURPLE_KEYRING_ERROR_INTERNAL, + _("Cannot request a password while quitting.")); cb(account, NULL, error, data); g_error_free(error); return; @@ -838,9 +829,9 @@ if (cb == NULL) return; - error = g_error_new(PURPLE_KEYRING_ERROR, - PURPLE_KEYRING_ERROR_NOKEYRING, - _("No keyring configured.")); + error = g_error_new_literal(PURPLE_KEYRING_ERROR, + PURPLE_KEYRING_ERROR_NOKEYRING, + _("No keyring configured.")); cb(account, NULL, error, data); g_error_free(error); return; @@ -900,9 +891,9 @@ "quitting.\n"); if (cb == NULL) return; - error = g_error_new(PURPLE_KEYRING_ERROR, - PURPLE_KEYRING_ERROR_INTERNAL, - _("Cannot save a password while quitting.")); + error = g_error_new_literal( + PURPLE_KEYRING_ERROR, PURPLE_KEYRING_ERROR_INTERNAL, + _("Cannot save a password while quitting.")); cb(account, error, data); g_error_free(error); return; @@ -913,9 +904,9 @@ "password migration.\n"); if (cb == NULL) return; - error = g_error_new(PURPLE_KEYRING_ERROR, - PURPLE_KEYRING_ERROR_INTERNAL, - _("Cannot save a password during password migration.")); + error = g_error_new_literal( + PURPLE_KEYRING_ERROR, PURPLE_KEYRING_ERROR_INTERNAL, + _("Cannot save a password during password migration.")); cb(account, error, data); g_error_free(error); return; @@ -925,9 +916,9 @@ if (inuse == NULL) { if (cb == NULL) return; - error = g_error_new(PURPLE_KEYRING_ERROR, - PURPLE_KEYRING_ERROR_NOKEYRING, - _("No keyring configured.")); + error = g_error_new_literal(PURPLE_KEYRING_ERROR, + PURPLE_KEYRING_ERROR_NOKEYRING, + _("No keyring configured.")); cb(account, error, data); g_error_free(error); return;
--- a/libpurple/plugins/keyrings/internalkeyring.c Wed Oct 02 19:25:51 2019 -0400 +++ b/libpurple/plugins/keyrings/internalkeyring.c Wed Oct 02 19:56:45 2019 -0400 @@ -441,9 +441,9 @@ } else if (open) g_assert_not_reached(); else if (req->cb.read != NULL /* || req->cb.write != NULL */ ) { - GError *error = g_error_new(PURPLE_KEYRING_ERROR, - PURPLE_KEYRING_ERROR_CANCELLED, - _("Operation cancelled.")); + GError *error = g_error_new_literal(PURPLE_KEYRING_ERROR, + PURPLE_KEYRING_ERROR_CANCELLED, + _("Operation cancelled.")); if (req->type == INTKEYRING_REQUEST_READ) { req->cb.read(req->account, NULL, error, req->cb_data); @@ -686,9 +686,9 @@ purple_account_get_username(account), purple_account_get_protocol_id(account)); } - error = g_error_new(PURPLE_KEYRING_ERROR, - PURPLE_KEYRING_ERROR_NOPASSWORD, - _("Password not found.")); + error = g_error_new_literal(PURPLE_KEYRING_ERROR, + PURPLE_KEYRING_ERROR_NOPASSWORD, + _("Password not found.")); if (cb != NULL) cb(account, NULL, error, data); g_error_free(error); @@ -806,11 +806,9 @@ } return TRUE; } else { - if (error != NULL) { - *error = g_error_new(PURPLE_KEYRING_ERROR, - PURPLE_KEYRING_ERROR_BACKENDFAIL, - _("Invalid password storage mode.")); - } + g_set_error_literal(error, PURPLE_KEYRING_ERROR, + PURPLE_KEYRING_ERROR_BACKENDFAIL, + _("Invalid password storage mode.")); return FALSE; } }
--- a/libpurple/plugins/keyrings/secretservice.c Wed Oct 02 19:25:51 2019 -0400 +++ b/libpurple/plugins/keyrings/secretservice.c Wed Oct 02 19:56:45 2019 -0400 @@ -87,9 +87,9 @@ old_error = *error; if (g_error_matches(old_error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { - new_error = g_error_new(PURPLE_KEYRING_ERROR, - PURPLE_KEYRING_ERROR_CANCELLED, - _("Operation cancelled.")); + new_error = g_error_new_literal(PURPLE_KEYRING_ERROR, + PURPLE_KEYRING_ERROR_CANCELLED, + _("Operation cancelled.")); } else if (g_error_matches(old_error, G_DBUS_ERROR, G_DBUS_ERROR_SPAWN_SERVICE_NOT_FOUND) || g_error_matches(old_error, G_DBUS_ERROR,
--- a/libpurple/protocols.c Wed Oct 02 19:25:51 2019 -0400 +++ b/libpurple/protocols.c Wed Oct 02 19:56:45 2019 -0400 @@ -578,33 +578,33 @@ PurpleProtocolClass *klass; if (protocol_type == G_TYPE_INVALID) { - g_set_error(error, PURPLE_PROTOCOLS_DOMAIN, 0, - _("Protocol type is not registered")); + g_set_error_literal(error, PURPLE_PROTOCOLS_DOMAIN, 0, + _("Protocol type is not registered")); return NULL; } if (!g_type_is_a(protocol_type, PURPLE_TYPE_PROTOCOL)) { - g_set_error(error, PURPLE_PROTOCOLS_DOMAIN, 0, - _("Protocol type does not inherit PurpleProtocol")); + g_set_error_literal(error, PURPLE_PROTOCOLS_DOMAIN, 0, + _("Protocol type does not inherit PurpleProtocol")); return NULL; } if (G_TYPE_IS_ABSTRACT(protocol_type)) { - g_set_error(error, PURPLE_PROTOCOLS_DOMAIN, 0, - _("Protocol type is abstract")); + g_set_error_literal(error, PURPLE_PROTOCOLS_DOMAIN, 0, + _("Protocol type is abstract")); return NULL; } protocol = g_object_new(protocol_type, NULL); if (!protocol) { - g_set_error(error, PURPLE_PROTOCOLS_DOMAIN, 0, - _("Could not create protocol instance")); + g_set_error_literal(error, PURPLE_PROTOCOLS_DOMAIN, 0, + _("Could not create protocol instance")); return NULL; } if (!purple_protocol_get_id(protocol)) { - g_set_error(error, PURPLE_PROTOCOLS_DOMAIN, 0, - _("Protocol does not provide an ID")); + g_set_error_literal(error, PURPLE_PROTOCOLS_DOMAIN, 0, + _("Protocol does not provide an ID")); g_object_unref(protocol); return NULL;
--- a/libpurple/protocols/facebook/api.c Wed Oct 02 19:25:51 2019 -0400 +++ b/libpurple/protocols/facebook/api.c Wed Oct 02 19:56:45 2019 -0400 @@ -87,6 +87,9 @@ GDestroyNotify func; }; +static void fb_api_error_literal(FbApi *api, FbApiError error, + const gchar *msg); + static void fb_api_attach(FbApi *api, FbId aid, const gchar *msgid, FbApiMessage *msg); @@ -597,7 +600,7 @@ priv = api->priv; if (G_UNLIKELY(size == 0)) { - fb_api_error(api, FB_API_ERROR_GENERAL, _("Empty JSON data")); + fb_api_error_literal(api, FB_API_ERROR_GENERAL, _("Empty JSON data")); return FALSE; } @@ -667,7 +670,7 @@ } if (msg != NULL) { - fb_api_error(api, errc, "%s", msg); + fb_api_error_literal(api, errc, msg); json_node_free(root); g_free(msg); return FALSE; @@ -875,8 +878,8 @@ hata = purple_http_response_get_data(res, NULL); if (!purple_strequal(hata, "true")) { - fb_api_error(api, FB_API_ERROR, - _("Failed generic API operation")); + fb_api_error_literal(api, FB_API_ERROR, + _("Failed generic API operation")); } } @@ -1086,8 +1089,8 @@ priv->unread = fb_json_values_next_int(values, 0); if (priv->sid == 0) { - fb_api_error(api, FB_API_ERROR_GENERAL, - _("Failed to get sync_sequence_id")); + fb_api_error_literal(api, FB_API_ERROR_GENERAL, + _("Failed to get sync_sequence_id")); } else { fb_api_connect_queue(api); } @@ -1162,8 +1165,8 @@ ); if (!fb_json_values_next_bool(values, TRUE)) { - fb_api_error(api, FB_API_ERROR_GENERAL, - _("Failed to mark thread as read")); + fb_api_error_literal(api, FB_API_ERROR_GENERAL, + _("Failed to mark thread as read")); } g_object_unref(values); @@ -1367,8 +1370,8 @@ fb_api_message_send(api, msg); } } else { - fb_api_error(api, FB_API_ERROR_GENERAL, - "Failed to send message"); + fb_api_error_literal(api, FB_API_ERROR_GENERAL, + "Failed to send message"); } g_object_unref(values); @@ -2027,6 +2030,18 @@ return priv->invisible; } +static void +fb_api_error_literal(FbApi *api, FbApiError error, const gchar *msg) +{ + GError *err; + + g_return_if_fail(FB_IS_API(api)); + + err = g_error_new_literal(FB_API_ERROR, error, msg); + + fb_api_error_emit(api, err); +} + void fb_api_error(FbApi *api, FbApiError error, const gchar *format, ...) { @@ -2208,8 +2223,8 @@ node = fb_json_node_get_nth(root, 0); if (node == NULL) { - fb_api_error(api, FB_API_ERROR_GENERAL, - _("Failed to obtain contact information")); + fb_api_error_literal(api, FB_API_ERROR_GENERAL, + _("Failed to obtain contact information")); json_node_free(root); return; } @@ -2696,8 +2711,8 @@ node = fb_json_node_get_nth(root, 0); if (node == NULL) { - fb_api_error(api, FB_API_ERROR_GENERAL, - _("Failed to obtain unread messages")); + fb_api_error_literal(api, FB_API_ERROR_GENERAL, + _("Failed to obtain unread messages")); json_node_free(root); return; } @@ -3029,8 +3044,8 @@ node = fb_json_node_get_nth(root, 0); if (node == NULL) { - fb_api_error(api, FB_API_ERROR_GENERAL, - _("Failed to obtain thread information")); + fb_api_error_literal(api, FB_API_ERROR_GENERAL, + _("Failed to obtain thread information")); json_node_free(root); return; } @@ -3042,8 +3057,8 @@ if (thrd.tid) { g_signal_emit_by_name(api, "thread-kicked", &thrd); } else { - fb_api_error(api, FB_API_ERROR_GENERAL, - _("Failed to parse thread information")); + fb_api_error_literal(api, FB_API_ERROR_GENERAL, + _("Failed to parse thread information")); } } else { fb_api_error_emit(api, err);
--- a/libpurple/protocols/facebook/mqtt.c Wed Oct 02 19:25:51 2019 -0400 +++ b/libpurple/protocols/facebook/mqtt.c Wed Oct 02 19:56:45 2019 -0400 @@ -284,6 +284,19 @@ g_error_free(err); } +static void +fb_mqtt_error_literal(FbMqtt *mqtt, FbMqttError error, const gchar *msg) +{ + GError *err; + + g_return_if_fail(FB_IS_MQTT(mqtt)); + + err = g_error_new_literal(FB_MQTT_ERROR, error, msg); + + g_signal_emit_by_name(mqtt, "error", err); + g_error_free(err); +} + void fb_mqtt_error(FbMqtt *mqtt, FbMqttError error, const gchar *format, ...) { @@ -307,7 +320,8 @@ FbMqttPrivate *priv = mqtt->priv; priv->tev = 0; - fb_mqtt_error(mqtt, FB_MQTT_ERROR_GENERAL, _("Connection timed out")); + fb_mqtt_error_literal(mqtt, FB_MQTT_ERROR_GENERAL, + _("Connection timed out")); return FALSE; } @@ -419,8 +433,8 @@ msg = fb_mqtt_message_new_bytes(priv->rbuf); if (G_UNLIKELY(msg == NULL)) { - fb_mqtt_error(mqtt, FB_MQTT_ERROR_GENERAL, - _("Failed to parse message")); + fb_mqtt_error_literal(mqtt, FB_MQTT_ERROR_GENERAL, + _("Failed to parse message")); return; } @@ -581,8 +595,8 @@ } /* Since no case returned, there was a parse error. */ - fb_mqtt_error(mqtt, FB_MQTT_ERROR_GENERAL, - _("Failed to parse message")); + fb_mqtt_error_literal(mqtt, FB_MQTT_ERROR_GENERAL, + _("Failed to parse message")); } static void @@ -617,8 +631,8 @@ bytes = fb_mqtt_message_bytes(msg); if (G_UNLIKELY(bytes == NULL)) { - fb_mqtt_error(mqtt, FB_MQTT_ERROR_GENERAL, - _("Failed to format data")); + fb_mqtt_error_literal(mqtt, FB_MQTT_ERROR_GENERAL, + _("Failed to format data")); return; } @@ -730,8 +744,7 @@ connected = (priv->conn != NULL) && priv->connected; if (!connected && error) { - fb_mqtt_error(mqtt, FB_MQTT_ERROR_GENERAL, - _("Not connected")); + fb_mqtt_error_literal(mqtt, FB_MQTT_ERROR_GENERAL, _("Not connected")); } return connected;
--- a/libpurple/protocols/irc/irc.c Wed Oct 02 19:25:51 2019 -0400 +++ b/libpurple/protocols/irc/irc.c Wed Oct 02 19:56:45 2019 -0400 @@ -256,7 +256,7 @@ if (!result) { purple_queued_output_stream_clear_queue(stream); - g_prefix_error(&error, _("Lost connection with server: ")); + g_prefix_error(&error, "%s", _("Lost connection with server: ")); purple_connection_take_error(gc, error); return; } @@ -570,7 +570,7 @@ res, &error); if (conn == NULL) { - g_prefix_error(&error, _("Unable to connect: ")); + g_prefix_error(&error, "%s", _("Unable to connect: ")); purple_connection_take_error(gc, error); return; } @@ -742,7 +742,7 @@ G_DATA_INPUT_STREAM(source), res, &len, &error); if (line == NULL && error != NULL) { - g_prefix_error(&error, _("Lost connection with server: ")); + g_prefix_error(&error, "%s", _("Lost connection with server: ")); purple_connection_take_error(gc, error); return; } else if (line == NULL) {
--- a/pidgin/gtkwhiteboard.c Wed Oct 02 19:25:51 2019 -0400 +++ b/pidgin/gtkwhiteboard.c Wed Oct 02 19:56:45 2019 -0400 @@ -478,7 +478,7 @@ /* Confirm whether the user really wants to clear */ GtkWidget *dialog = gtk_message_dialog_new( GTK_WINDOW(gtkwb), GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, + GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, "%s", _("Do you really want to clear?")); gint response = gtk_dialog_run(GTK_DIALOG(dialog)); gtk_widget_destroy(dialog);
--- a/pidgin/libpidgin.c Wed Oct 02 19:25:51 2019 -0400 +++ b/pidgin/libpidgin.c Wed Oct 02 19:56:45 2019 -0400 @@ -759,8 +759,8 @@ if (g_application_get_is_registered(app) && g_application_get_is_remote(app)) { - g_printerr(_("Exiting because another libpurple client is " - "already running.\n")); + g_printerr("%s\n", _("Exiting because another libpurple client is " + "already running.")); } /* Now that we're sure purple_core_quit() has been called,
--- a/pidgin/plugins/disco/xmppdisco.c Wed Oct 02 19:25:51 2019 -0400 +++ b/pidgin/plugins/disco/xmppdisco.c Wed Oct 02 19:56:45 2019 -0400 @@ -645,7 +645,8 @@ xmpp_protocol = purple_protocols_find(XMPP_PROTOCOL_ID); if (NULL == xmpp_protocol) { - g_set_error(error, PLUGIN_DOMAIN, 0, _("XMPP protocol is not loaded.")); + g_set_error_literal(error, PLUGIN_DOMAIN, 0, + _("XMPP protocol is not loaded.")); return FALSE; }
--- a/pidgin/plugins/xmppconsole/xmppconsole.c Wed Oct 02 19:25:51 2019 -0400 +++ b/pidgin/plugins/xmppconsole/xmppconsole.c Wed Oct 02 19:56:45 2019 -0400 @@ -764,7 +764,8 @@ } if (!any_registered) { - g_set_error(error, PLUGIN_DOMAIN, 0, _("No XMPP protocol is loaded.")); + g_set_error_literal(error, PLUGIN_DOMAIN, 0, + _("No XMPP protocol is loaded.")); return FALSE; }