Tue, 17 Sep 2024 14:31:28 -0500
Use the result of g_string_free(..., FALSE)
Thus silencing the warnings about unused results.
Testing Done:
Compiled with fewer warnings.
Reviewed at https://reviews.imfreedom.org/r/3509/
--- a/finch/plugins/gnttinyurl.c Tue Sep 17 03:53:30 2024 -0500 +++ b/finch/plugins/gnttinyurl.c Tue Sep 17 14:31:28 2024 -0500 @@ -274,8 +274,7 @@ urls = g_list_delete_link(urls, iter); } } - *message = t->str; - g_string_free(t, FALSE); + *message = g_string_free(t, FALSE); if (conv == NULL) conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, sender); purple_conversation_set_data(conv, "TinyURLs", urls);
--- a/libpurple/media/codec.c Tue Sep 17 03:53:30 2024 -0500 +++ b/libpurple/media/codec.c Tue Sep 17 14:31:28 2024 -0500 @@ -388,7 +388,6 @@ PurpleMediaCodecPrivate *priv; GString *string = NULL; GList *item; - gchar *charstring; const gchar *media_type_str = NULL; if (codec == NULL) @@ -415,9 +414,6 @@ param->key, (gchar *)param->value); } - charstring = string->str; - g_string_free (string, FALSE); - - return charstring; + return g_string_free(string, FALSE); }
--- a/libpurple/plugins/log_reader.c Tue Sep 17 03:53:30 2024 -0500 +++ b/libpurple/plugins/log_reader.c Tue Sep 17 14:31:28 2024 -0500 @@ -444,7 +444,6 @@ xmlnode *message; const char *session_id; int last_log; - GString *text; }; /* This function is really confusing. It makes baby rlaager cry... @@ -865,7 +864,6 @@ data->root = root; data->message = message; data->session_id = session_id; - data->text = NULL; data->last_log = FALSE; stamp = msn_logger_parse_timestamp(message, &tm); @@ -897,24 +895,14 @@ data = log->logger_data; - if (data->text) { - /* The GTK code which displays the logs g_free()s whatever is - * returned from this function. Thus, we can't reuse the str - * part of the GString. The only solution is to free it and - * start over. - */ - g_string_free(data->text, FALSE); - } - text = g_string_new(""); if (!data->root || !data->message || !data->session_id) { /* Something isn't allocated correctly. */ purple_debug_error("MSN log parse", "Error parsing message: %s\n", "Internal variables inconsistent"); - data->text = text; - - return text->str; + + return g_string_free(text, FALSE); } for (message = data->message; message; @@ -1157,9 +1145,7 @@ g_free(tmp); } - data->text = text; - - return text->str; + return g_string_free(text, FALSE); } static int msn_logger_size (PurpleLog *log) @@ -1190,9 +1176,6 @@ if (data->last_log) xmlnode_free(data->root); - if (data->text) - g_string_free(data->text, FALSE); - g_free(data); }
--- a/libpurple/protocols/gg/gg.c Tue Sep 17 03:53:30 2024 -0500 +++ b/libpurple/protocols/gg/gg.c Tue Sep 17 14:31:28 2024 -0500 @@ -1146,8 +1146,7 @@ } } - msg = message->str; - g_string_free(message, FALSE); + msg = g_string_free(message, FALSE); if (got_image) { info->pending_richtext_messages = g_list_append(info->pending_richtext_messages, msg);
--- a/libpurple/protocols/sametime/sametime.c Tue Sep 17 03:53:30 2024 -0500 +++ b/libpurple/protocols/sametime/sametime.c Tue Sep 17 14:31:28 2024 -0500 @@ -3932,10 +3932,7 @@ str = g_string_new(NULL); purple_mime_document_write(doc, str); - tmp = str->str; - g_string_free(str, FALSE); - - return tmp; + return g_string_free(str, FALSE); }
--- a/libpurple/protocols/silc10/util.c Tue Sep 17 03:53:30 2024 -0500 +++ b/libpurple/protocols/silc10/util.c Tue Sep 17 14:31:28 2024 -0500 @@ -534,12 +534,11 @@ if (mood & SILC_ATTRIBUTE_MOOD_ANXIOUS) g_string_append_printf(s, "[%s] ", _("Anxious")); } - if (strlen(s->str)) { - *moodstr = s->str; - g_string_free(s, FALSE); - g_strchomp(*moodstr); - } else + if (s->len != 0) { + *moodstr = g_strchomp(g_string_free(s, FALSE)); + } else { g_string_free(s, TRUE); + } attr = silcpurple_get_attr(attrs, SILC_ATTRIBUTE_STATUS_FREETEXT); memset(tmp, 0, sizeof(tmp)); @@ -564,12 +563,11 @@ if (contact & SILC_ATTRIBUTE_CONTACT_VIDEO) g_string_append_printf(s, "[%s] ", _("Video Conferencing")); } - if (strlen(s->str)) { - *contactstr = s->str; - g_string_free(s, FALSE); - g_strchomp(*contactstr); - } else + if (s->len != 0) { + *contactstr = g_strchomp(g_string_free(s, FALSE)); + } else { g_string_free(s, TRUE); + } attr = silcpurple_get_attr(attrs, SILC_ATTRIBUTE_PREFERRED_LANGUAGE); memset(tmp, 0, sizeof(tmp)); @@ -594,11 +592,11 @@ device.model ? device.model : "", device.language ? device.language : ""); } - if (strlen(s->str)) { - *devicestr = s->str; - g_string_free(s, FALSE); - } else + if (s->len != 0) { + *devicestr = g_string_free(s, FALSE); + } else { g_string_free(s, TRUE); + } attr = silcpurple_get_attr(attrs, SILC_ATTRIBUTE_TIMEZONE); memset(tmp, 0, sizeof(tmp));
--- a/libpurple/protocols/zephyr/zephyr.c Tue Sep 17 03:53:30 2024 -0500 +++ b/libpurple/protocols/zephyr/zephyr.c Tue Sep 17 14:31:28 2024 -0500 @@ -600,8 +600,7 @@ g_string_append_c(frames->text, *message++); } } - ret = frames->text->str; - g_string_free(frames->text, FALSE); + ret = g_string_free(frames->text, FALSE); g_free(frames); purple_debug_info("zephyr","zephyr outputted %s\n",ret); return ret; @@ -726,8 +725,7 @@ frames = frames->enclosing; g_free(curr); } - ret = frames->text->str; - g_string_free(frames->text, FALSE); + ret = g_string_free(frames->text, FALSE); g_free(frames); return ret; }