ACPI: Assert that we don't run out of the preallocated memory
PATCH 1/1 ACPI: Assert that we don't run out of the preallocated memory
data_length is a constant value, so we use assert instead of condition check.
---
1. Address Peter and Michael's comments to use assert instead of if().
https://lore.kernel.org/qemu-devel/[email protected]/
--- hw/acpi/ghes.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
hw/acpi/ghes.c +4 -8
@@ -204,16 +204,12 @@ static int acpi_ghes_record_mem_error(uint64_t error_block_address,/* This is the length if adding a new generic error data entry*/ data_length =ACPI_GHES_DATA_LENGTH +ACPI_GHES_MEM_CPER_LENGTH ; -/* -* Check whether it will run out of the preallocated memory if adding a new -* generic error data entry +* It should not run out of the preallocated memory if adding a new generic +* error data entry */ -if ((data_length +ACPI_GHES_GESB_SIZE ) >ACPI_GHES_MAX_RAW_DATA_LENGTH ) { -error_report ("Not enough memory to record new CPER!!!" ); -g_array_free (block, true); -return -1 ; - } +assert ((data_length +ACPI_GHES_GESB_SIZE ) <= +ACPI_GHES_MAX_RAW_DATA_LENGTH );/* Build the new generic error status block header */ acpi_ghes_generic_error_status(block, ACPI_GEBS_UNCORRECTABLE,
Signature · 1 line
2.17.1
Quoted 8 lines · Dongjiu Geng
data_lengthis a constant value, so we use assert instead of condition check.Signed-off-by Dongjiu Geng <[email protected]>---
1. Address Peter and Michael's comments to use assert instead ofif().
https://lore.kernel.org/qemu-devel/[email protected]/
Oops, looks like we forgot about this patch -- Michael, are you taking it through your tree or should I take it via target-arm ?
thanks
-- PMM
Michael S. Tsirkin
Reviewed-byQuoted 10 lines · Peter Maydell
Quoted 8 lines · Dongjiu Geng
data_lengthis a constant value, so we use assert instead of condition check.Signed-off-by Dongjiu Geng <[email protected]>---
1. Address Peter and Michael's comments to use assert instead ofif().
https://lore.kernel.org/qemu-devel/[email protected]/
Quoted 5 lines
Oops, looks like we forgot about this patch -- Michael, are you taking it through your tree or should I take it via target-arm ?
thanks
-- PMM
Feel free to merge pls.
Peter Maydell
AppliedQuoted 12 lines · Michael S. Tsirkin
Quoted 10 lines · Peter Maydell
Quoted 8 lines · Dongjiu Geng
data_lengthis a constant value, so we use assert instead of condition check.Signed-off-by Dongjiu Geng <[email protected]>---
1. Address Peter and Michael's comments to use assert instead ofif().
https://lore.kernel.org/qemu-devel/[email protected]/
Quoted 8 lines
Quoted 5 lines
Oops, looks like we forgot about this patch -- Michael, are you taking it through your tree or should I take it via target-arm ?
thanks
-- PMMFeel free to merge pls.
Reviewed-by Michael S. Tsirkin <[email protected]>
Applied to target-arm.next, thanks.
-- PMM