From fc8525f0535ccc405d5fa2f1c225dfe73ee8b8ff Mon Sep 17 00:00:00 2001 From: Matt Mundell Date: Wed, 27 Sep 2023 13:39:07 +0200 Subject: [PATCH 1/2] Remove unused return strings --- src/gsad_gmp.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/src/gsad_gmp.c b/src/gsad_gmp.c index 85b8a7501..c666195bb 100644 --- a/src/gsad_gmp.c +++ b/src/gsad_gmp.c @@ -5599,7 +5599,6 @@ char * restore_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data) { - GString *xml; gchar *ret; entity_t entity; const char *target_id; @@ -5608,8 +5607,6 @@ restore_gmp (gvm_connection_t *connection, credentials_t *credentials, CHECK_VARIABLE_INVALID (target_id, "Restore") - xml = g_string_new (""); - /* Restore the resource. */ if (gvm_connection_sendf (connection, @@ -5618,7 +5615,6 @@ restore_gmp (gvm_connection_t *connection, credentials_t *credentials, target_id) == -1) { - g_string_free (xml, TRUE); cmd_response_data_set_status_code (response_data, MHD_HTTP_INTERNAL_SERVER_ERROR); return gsad_message ( @@ -5629,9 +5625,8 @@ restore_gmp (gvm_connection_t *connection, credentials_t *credentials, response_data); } - if (read_entity_and_string_c (connection, &entity, &xml)) + if (read_entity_and_string_c (connection, &entity, NULL)) { - g_string_free (xml, TRUE); cmd_response_data_set_status_code (response_data, MHD_HTTP_INTERNAL_SERVER_ERROR); return gsad_message ( @@ -5647,7 +5642,6 @@ restore_gmp (gvm_connection_t *connection, credentials_t *credentials, ret = response_from_entity (connection, credentials, params, entity, "Restore", response_data); free_entity (entity); - g_string_free (xml, FALSE); return ret; } @@ -5665,17 +5659,13 @@ char * empty_trashcan_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data) { - GString *xml; gchar *ret; entity_t entity; - xml = g_string_new (""); - /* Empty the trash. */ if (gvm_connection_sendf (connection, "") == -1) { - g_string_free (xml, TRUE); cmd_response_data_set_status_code (response_data, MHD_HTTP_INTERNAL_SERVER_ERROR); return gsad_message ( @@ -5685,9 +5675,8 @@ empty_trashcan_gmp (gvm_connection_t *connection, credentials_t *credentials, response_data); } - if (read_entity_and_string_c (connection, &entity, &xml)) + if (read_entity_and_string_c (connection, &entity, NULL)) { - g_string_free (xml, TRUE); cmd_response_data_set_status_code (response_data, MHD_HTTP_INTERNAL_SERVER_ERROR); return gsad_message ( @@ -5702,7 +5691,6 @@ empty_trashcan_gmp (gvm_connection_t *connection, credentials_t *credentials, ret = response_from_entity (connection, credentials, params, entity, "Empty Trashcan", response_data); free_entity (entity); - g_string_free (xml, FALSE); return ret; } From c60a8f701afd18cfb3d32ce9a7dedca63a30a8be Mon Sep 17 00:00:00 2001 From: Matt Mundell Date: Wed, 27 Sep 2023 13:39:14 +0200 Subject: [PATCH 2/2] Use result of g_string_free when arg 2 is FALSE --- src/gsad_gmp_arguments.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/gsad_gmp_arguments.c b/src/gsad_gmp_arguments.c index c57f3f978..a188e651a 100644 --- a/src/gsad_gmp_arguments.c +++ b/src/gsad_gmp_arguments.c @@ -71,11 +71,7 @@ gmp_arguments_string (gmp_arguments_t *arguments) g_free (escaped_value); } - gchar *retval = argumentslist->str; - - g_string_free (argumentslist, FALSE); - - return retval; + return g_string_free (argumentslist, FALSE); } gboolean