You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2024/05/17 11:15:56 UTC

(nuttx) branch master updated: fix: call rwb->rhreload() when nblocks > 0

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 1d19c6abe3 fix: call rwb->rhreload() when nblocks > 0
1d19c6abe3 is described below

commit 1d19c6abe3552cc26d434cadd4f16f7bd3bc88ea
Author: ChenChuang <ch...@ninebot.com>
AuthorDate: Fri May 17 16:19:42 2024 +0800

    fix: call rwb->rhreload() when nblocks > 0
    
    There is no need to call rwb->rhreloade() when nblocks is 0,
    and some platform(eg: BES) has the limit that the parameter
    of len in pltatform flash read function cant't be 0.
---
 drivers/misc/rwbuffer.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/misc/rwbuffer.c b/drivers/misc/rwbuffer.c
index 4975227c69..8e57625dcf 100644
--- a/drivers/misc/rwbuffer.c
+++ b/drivers/misc/rwbuffer.c
@@ -352,8 +352,8 @@ static ssize_t rwb_writebuffer(FAR struct rwbuffer_s *rwb,
 
       padblocks = startblock % rwb->wralignblocks;
       rwb->wrblockstart = startblock - padblocks;
-      rwb_read_(rwb, rwb->wrblockstart, padblocks, rwb->wrbuffer);
       rwb->wrnblocks = padblocks;
+      rwb_read_(rwb, rwb->wrblockstart, padblocks, rwb->wrbuffer);
 
       if (remain > rwb->wrmaxblocks - padblocks)
         {
@@ -977,7 +977,10 @@ static ssize_t rwb_read_(FAR struct rwbuffer_s *rwb, off_t startblock,
        * the user buffer.
        */
 
-      ret = rwb->rhreload(rwb->dev, rdbuffer, startblock, nblocks);
+      if (nblocks)
+        {
+          ret = rwb->rhreload(rwb->dev, rdbuffer, startblock, nblocks);
+        }
     }
 
   return ret;