W dniu 22.09.2013 09:29, Hanjun Guo pisze:
On 2013-9-20 0:18, Tomasz Nowicki wrote:
tools/bfapei/bfapei.c | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-)
Add some simple change log would be great, something like: add a helper function to ....
Sure, I will do that.
Tomasz
and the Signed-off-by is missing :)
diff --git a/tools/bfapei/bfapei.c b/tools/bfapei/bfapei.c index 7b347e9..73a421c 100644 --- a/tools/bfapei/bfapei.c +++ b/tools/bfapei/bfapei.c @@ -125,6 +125,22 @@ static uint64_t obtain_esb(char *homedir, char *manifest_name) return 0; }
+static int bfapei_expand_buf(char **buf, int *size, int reqr_size) +{
- if (*size >= reqr_size)
return BFAPEI_OK;
- *buf = realloc(*buf, reqr_size);
- if (!(*buf)) {
printf("Error during memory allocation!\n");
return BFAPEI_FAIL;
- }
- memset(*buf + *size, 0, reqr_size - *size);
- *size = reqr_size;
- return BFAPEI_OK;
+}
- static int bfapei_hest(char **buf, int *size, uint64_t paddr, int status) { struct acpi_hest_generic_status *block_ptr;
@@ -136,15 +152,8 @@ static int bfapei_hest(char **buf, int *size, uint64_t paddr, int status) sizeof(struct acpi_hest_generic_data) + sizeof (struct cper_sec_mem_err);
- if (*size < reqr_size) {
*buf = realloc(*buf, *size + reqr_size);
if (!(*buf)) {
printf("Error during memory allocation!\n");
return BFAPEI_FAIL;
}
memset(*buf + *size, 0, reqr_size - *size);
*size += reqr_size;
- }
if (bfapei_expand_buf(buf, size, reqr_size))
return BFAPEI_FAIL;
/*
- Fill in blob which will be parsed by GHES driver.
@@ -175,17 +184,10 @@ static int bfapei_hest(char **buf, int *size, uint64_t paddr, int status)
static int bfapei_erst(char **buf, int *size, uint64_t paddr) {
- int reqr_size = 0x400;
- int reqr_size = 0x200;
- if (*size < reqr_size) {
*buf = realloc(*buf, *size + reqr_size);
if (!(*buf)) {
printf("Error during memory allocation!\n");
return BFAPEI_FAIL;
}
memset(*buf + *size, 0, reqr_size - *size);
*size += reqr_size;
- }
if (bfapei_expand_buf(buf, size, reqr_size))
return BFAPEI_FAIL;
/*
- Fill in ERST registers.