diff --git a/libfwupdplugin/fu-security-attrs.c b/libfwupdplugin/fu-security-attrs.c index 0a348c074..739aef07c 100644 --- a/libfwupdplugin/fu-security-attrs.c +++ b/libfwupdplugin/fu-security-attrs.c @@ -204,7 +204,7 @@ fu_security_attrs_calculate_hsi(FuSecurityAttrs *self, FuSecurityAttrsFlags flag { guint hsi_number = 0; FwupdSecurityAttrFlags attr_flags = FWUPD_SECURITY_ATTR_FLAG_NONE; - GString *str = g_string_new("HSI:"); + g_autoptr(GString) str = g_string_new("HSI:"); const FwupdSecurityAttrFlags hpi_suffixes[] = { FWUPD_SECURITY_ATTR_FLAG_RUNTIME_ISSUE, FWUPD_SECURITY_ATTR_FLAG_NONE, @@ -247,10 +247,8 @@ fu_security_attrs_calculate_hsi(FuSecurityAttrs *self, FuSecurityAttrsFlags flag if (fwupd_security_attr_has_flag(attr, FWUPD_SECURITY_ATTR_FLAG_RUNTIME_ISSUE) && fwupd_security_attr_has_flag(attr, FWUPD_SECURITY_ATTR_FLAG_SUCCESS)) continue; - if (fwupd_security_attr_has_flag(attr, FWUPD_SECURITY_ATTR_FLAG_MISSING_DATA)) { - g_string_append(str, "INVALID:missing-data"); - return g_string_free(str, FALSE); - } + if (fwupd_security_attr_has_flag(attr, FWUPD_SECURITY_ATTR_FLAG_MISSING_DATA)) + return g_strdup("HSI:INVALID:missing-data"); attr_flags |= fwupd_security_attr_get_flags(attr); } @@ -273,7 +271,7 @@ fu_security_attrs_calculate_hsi(FuSecurityAttrs *self, FuSecurityAttrsFlags flag FWUPD_MICRO_VERSION); } - return g_string_free(str, FALSE); + return g_string_free(g_steal_pointer(&str), FALSE); } static gchar * diff --git a/plugins/logitech-hidpp/fu-logitech-hidpp-hidpp.c b/plugins/logitech-hidpp/fu-logitech-hidpp-hidpp.c index 1d54acc68..dc16fa192 100644 --- a/plugins/logitech-hidpp/fu-logitech-hidpp-hidpp.c +++ b/plugins/logitech-hidpp/fu-logitech-hidpp-hidpp.c @@ -14,10 +14,10 @@ static gchar * fu_logitech_hidpp_msg_to_string(FuLogitechHidPpHidppMsg *msg) { - GString *str = g_string_new(NULL); const gchar *tmp; g_autoptr(GError) error = NULL; g_autoptr(GString) flags_str = g_string_new(NULL); + g_autoptr(GString) str = g_string_new(NULL); g_return_val_if_fail(msg != NULL, NULL); @@ -53,7 +53,7 @@ fu_logitech_hidpp_msg_to_string(FuLogitechHidPpHidppMsg *msg) if (!fu_logitech_hidpp_msg_is_error(msg, &error)) { g_string_append_printf(str, "error: %s\n", error->message); } - return g_string_free(str, FALSE); + return g_string_free(g_steal_pointer(&str), FALSE); } gboolean diff --git a/src/fu-util-common.c b/src/fu-util-common.c index 91621b9c6..020b2da38 100644 --- a/src/fu-util-common.c +++ b/src/fu-util-common.c @@ -1862,9 +1862,9 @@ fu_util_release_to_string(FwupdRelease *rel, guint idt) const gchar *tmp2; GPtrArray *issues = fwupd_release_get_issues(rel); GPtrArray *tags = fwupd_release_get_tags(rel); - GString *str = g_string_new(NULL); guint64 flags = fwupd_release_get_flags(rel); g_autofree gchar *desc_fb = NULL; + g_autoptr(GString) str = g_string_new(NULL); g_return_val_if_fail(FWUPD_IS_RELEASE(rel), NULL); @@ -2022,17 +2022,17 @@ fu_util_release_to_string(FwupdRelease *rel, guint idt) tag_strs); } - return g_string_free(str, FALSE); + return g_string_free(g_steal_pointer(&str), FALSE); } gchar * fu_util_remote_to_string(FwupdRemote *remote, guint idt) { - GString *str = g_string_new(NULL); FwupdRemoteKind kind = fwupd_remote_get_kind(remote); FwupdKeyringKind keyring_kind = fwupd_remote_get_keyring_kind(remote); const gchar *tmp; gint priority; + g_autoptr(GString) str = g_string_new(NULL); g_return_val_if_fail(FWUPD_IS_REMOTE(remote), NULL); @@ -2149,7 +2149,7 @@ fu_util_remote_to_string(FwupdRemote *remote, guint idt) fwupd_remote_get_automatic_reports(remote) ? "true" : "false"); } - return g_string_free(str, FALSE); + return g_string_free(g_steal_pointer(&str), FALSE); } static void