drivers/bch: Handle return value of bchlib_readsector()

This commit is contained in:
Kenneth Thompson 2021-08-03 22:04:10 -07:00 committed by Xiang Xiao
parent 59b9a30592
commit 9d29d4bef5
2 changed files with 20 additions and 4 deletions

View File

@ -99,7 +99,11 @@ ssize_t bchlib_read(FAR void *handle, FAR char *buffer, size_t offset,
{
/* Read the sector into the sector buffer */
bchlib_readsector(bch, sector);
ret = bchlib_readsector(bch, sector);
if (ret < 0)
{
return ret;
}
/* Copy the tail end of the sector to the user buffer */
@ -169,7 +173,11 @@ ssize_t bchlib_read(FAR void *handle, FAR char *buffer, size_t offset,
{
/* Read the sector into the sector buffer */
bchlib_readsector(bch, sector);
ret = bchlib_readsector(bch, sector);
if (ret < 0)
{
return ret;
}
/* Copy the head end of the sector to the user buffer */

View File

@ -84,7 +84,11 @@ ssize_t bchlib_write(FAR void *handle, FAR const char *buffer, size_t offset,
{
/* Read the full sector into the sector buffer */
bchlib_readsector(bch, sector);
ret = bchlib_readsector(bch, sector);
if (ret < 0)
{
return ret;
}
/* Copy the tail end of the sector from the user buffer */
@ -166,7 +170,11 @@ ssize_t bchlib_write(FAR void *handle, FAR const char *buffer, size_t offset,
{
/* Read the sector into the sector buffer */
bchlib_readsector(bch, sector);
ret = bchlib_readsector(bch, sector);
if (ret < 0)
{
return ret;
}
/* Copy the head end of the sector from the user buffer */