Skip to content

Commit

Permalink
blocklevel: smart_write: Rename write buffer
Browse files Browse the repository at this point in the history
The buffer is only used for ECC protected partitions, so lets call it
ecc_buf for clarity.

Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
  • Loading branch information
amboar authored and oohal committed Oct 14, 2019
1 parent 8f204c1 commit 5c935e7
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions libflash/blocklevel.c
Expand Up @@ -508,7 +508,7 @@ int blocklevel_smart_write(struct blocklevel_device *bl, uint64_t pos, const voi
{
uint32_t erase_size;
const void *write_buf = buf;
void *write_buf_start = NULL;
void *ecc_buf = NULL;
uint64_t ecc_start;
void *erase_buf;
int rc = 0;
Expand All @@ -534,18 +534,18 @@ int blocklevel_smart_write(struct blocklevel_device *bl, uint64_t pos, const voi

len = ecc_buffer_size(len);

write_buf_start = malloc(len);
if (!write_buf_start) {
ecc_buf = malloc(len);
if (!ecc_buf) {
errno = ENOMEM;
return FLASH_ERR_MALLOC_FAILED;
}

if (memcpy_to_ecc(write_buf_start, buf, ecc_buffer_size_minus_ecc(len))) {
free(write_buf_start);
if (memcpy_to_ecc(ecc_buf, buf, ecc_buffer_size_minus_ecc(len))) {
free(ecc_buf);
errno = EBADF;
return FLASH_ERR_ECC_INVALID;
}
write_buf = write_buf_start;
write_buf = ecc_buf;
}

erase_buf = malloc(erase_size);
Expand Down Expand Up @@ -599,7 +599,7 @@ int blocklevel_smart_write(struct blocklevel_device *bl, uint64_t pos, const voi
out:
release(bl);
out_free:
free(write_buf_start);
free(ecc_buf);
free(erase_buf);
return rc;
}
Expand Down

0 comments on commit 5c935e7

Please sign in to comment.