[PATCH 1/5] acpi/ghes: Automate data block cleanup in acpi_ghes_memory_errors()

Gavin Shan posted 5 patches 2 months, 2 weeks ago
Maintainers: "Michael S. Tsirkin" <mst@redhat.com>, Igor Mammedov <imammedo@redhat.com>, Ani Sinha <anisinha@redhat.com>, Dongjiu Geng <gengdongjiu1@gmail.com>, Peter Maydell <peter.maydell@linaro.org>, Paolo Bonzini <pbonzini@redhat.com>
There is a newer version of this series
[PATCH 1/5] acpi/ghes: Automate data block cleanup in acpi_ghes_memory_errors()
Posted by Gavin Shan 2 months, 2 weeks ago
Use g_auto_ptr() to automate data block cleanup in the function so
that it won't be a burden to us.

Suggested-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Gavin Shan <gshan@redhat.com>
---
 hw/acpi/ghes.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/hw/acpi/ghes.c b/hw/acpi/ghes.c
index 06555905ce..6366c74248 100644
--- a/hw/acpi/ghes.c
+++ b/hw/acpi/ghes.c
@@ -565,9 +565,7 @@ int acpi_ghes_memory_errors(AcpiGhesState *ags, uint16_t source_id,
                   0xED, 0x7C, 0x83, 0xB1);
     Error *errp = NULL;
     int data_length;
-    GArray *block;
-
-    block = g_array_new(false, true /* clear */, 1);
+    g_autoptr(GArray) block = g_array_new(false, true /* clear */, 1);
 
     data_length = ACPI_GHES_DATA_LENGTH + ACPI_GHES_MEM_CPER_LENGTH;
     /*
@@ -585,8 +583,6 @@ int acpi_ghes_memory_errors(AcpiGhesState *ags, uint16_t source_id,
     /* Report the error */
     ghes_record_cper_errors(ags, block->data, block->len, source_id, &errp);
 
-    g_array_free(block, true);
-
     if (errp) {
         error_report_err(errp);
         return -1;
-- 
2.51.1
Re: [PATCH 1/5] acpi/ghes: Automate data block cleanup in acpi_ghes_memory_errors()
Posted by Igor Mammedov 2 months, 1 week ago
On Thu, 27 Nov 2025 10:44:31 +1000
Gavin Shan <gshan@redhat.com> wrote:

> Use g_auto_ptr() to automate data block cleanup in the function so
> that it won't be a burden to us.
> 
> Suggested-by: Markus Armbruster <armbru@redhat.com>
> Signed-off-by: Gavin Shan <gshan@redhat.com>

Reviewed-by: Igor Mammedov <imammedo@redhat.com>

> ---
>  hw/acpi/ghes.c | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/hw/acpi/ghes.c b/hw/acpi/ghes.c
> index 06555905ce..6366c74248 100644
> --- a/hw/acpi/ghes.c
> +++ b/hw/acpi/ghes.c
> @@ -565,9 +565,7 @@ int acpi_ghes_memory_errors(AcpiGhesState *ags, uint16_t source_id,
>                    0xED, 0x7C, 0x83, 0xB1);
>      Error *errp = NULL;
>      int data_length;
> -    GArray *block;
> -
> -    block = g_array_new(false, true /* clear */, 1);
> +    g_autoptr(GArray) block = g_array_new(false, true /* clear */, 1);
>  
>      data_length = ACPI_GHES_DATA_LENGTH + ACPI_GHES_MEM_CPER_LENGTH;
>      /*
> @@ -585,8 +583,6 @@ int acpi_ghes_memory_errors(AcpiGhesState *ags, uint16_t source_id,
>      /* Report the error */
>      ghes_record_cper_errors(ags, block->data, block->len, source_id, &errp);
>  
> -    g_array_free(block, true);
> -
>      if (errp) {
>          error_report_err(errp);
>          return -1;
Re: [PATCH 1/5] acpi/ghes: Automate data block cleanup in acpi_ghes_memory_errors()
Posted by Markus Armbruster 2 months, 2 weeks ago
Gavin Shan <gshan@redhat.com> writes:

> Use g_auto_ptr() to automate data block cleanup in the function so
> that it won't be a burden to us.
>
> Suggested-by: Markus Armbruster <armbru@redhat.com>
> Signed-off-by: Gavin Shan <gshan@redhat.com>

Reviewed-by: Markus Armbruster <armbru@redhat.com>