From 02ea79365a0921e9153c19310d34c0f18d199a9f Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Sun, 17 Jul 2022 20:17:21 +0800 Subject: [PATCH] drivers/bch: Adjust f_pos with the correct value Fix the problem reported by: https://github.com/apache/incubator-nuttx/issues/6619 Signed-off-by: Xiang Xiao --- drivers/bch/bchdev_driver.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/bch/bchdev_driver.c b/drivers/bch/bchdev_driver.c index 151e62f5b1..b51e73a0a2 100644 --- a/drivers/bch/bchdev_driver.c +++ b/drivers/bch/bchdev_driver.c @@ -294,7 +294,7 @@ static ssize_t bch_read(FAR struct file *filep, FAR char *buffer, size_t len) { FAR struct inode *inode = filep->f_inode; FAR struct bchlib_s *bch; - int ret; + ssize_t ret; DEBUGASSERT(inode && inode->i_private); bch = (FAR struct bchlib_s *)inode->i_private; @@ -302,13 +302,13 @@ static ssize_t bch_read(FAR struct file *filep, FAR char *buffer, size_t len) ret = bchlib_semtake(bch); if (ret < 0) { - return (ssize_t)ret; + return ret; } ret = bchlib_read(bch, buffer, filep->f_pos, len); if (ret > 0) { - filep->f_pos += len; + filep->f_pos += ret; } bchlib_semgive(bch); @@ -324,7 +324,7 @@ static ssize_t bch_write(FAR struct file *filep, FAR const char *buffer, { FAR struct inode *inode = filep->f_inode; FAR struct bchlib_s *bch; - int ret = -EACCES; + ssize_t ret = -EACCES; DEBUGASSERT(inode && inode->i_private); bch = (FAR struct bchlib_s *)inode->i_private; @@ -334,13 +334,13 @@ static ssize_t bch_write(FAR struct file *filep, FAR const char *buffer, ret = bchlib_semtake(bch); if (ret < 0) { - return (ssize_t)ret; + return ret; } ret = bchlib_write(bch, buffer, filep->f_pos, len); if (ret > 0) { - filep->f_pos += len; + filep->f_pos += ret; } bchlib_semgive(bch);