This is an automated email from the ASF dual-hosted git repository. davids5 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit a86a3d4d02373f8f0fd36e0431bfef77cefeb12c Author: Xiang Xiao <xiaoxi...@xiaomi.com> AuthorDate: Fri Aug 21 19:39:40 2020 +0800 drivers/rwbuffer: Remove the redundant check in rwb_initialize the same check already done before Signed-off-by: Xiang Xiao <xiaoxi...@xiaomi.com> --- drivers/rwbuffer.c | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/drivers/rwbuffer.c b/drivers/rwbuffer.c index 970e6a7..45a7aa5 100644 --- a/drivers/rwbuffer.c +++ b/drivers/rwbuffer.c @@ -828,16 +828,12 @@ int rwb_initialize(FAR struct rwbuffer_s *rwb) /* Allocate the write buffer */ - rwb->wrbuffer = NULL; - if (rwb->wrmaxblocks > 0) + allocsize = rwb->wrmaxblocks * rwb->blocksize; + rwb->wrbuffer = kmm_malloc(allocsize); + if (!rwb->wrbuffer) { - allocsize = rwb->wrmaxblocks * rwb->blocksize; - rwb->wrbuffer = kmm_malloc(allocsize); - if (!rwb->wrbuffer) - { - ferr("Write buffer kmm_malloc(%d) failed\n", allocsize); - return -ENOMEM; - } + ferr("Write buffer kmm_malloc(%d) failed\n", allocsize); + return -ENOMEM; } finfo("Write buffer size: %d bytes\n", allocsize); @@ -859,16 +855,12 @@ int rwb_initialize(FAR struct rwbuffer_s *rwb) /* Allocate the read-ahead buffer */ - rwb->rhbuffer = NULL; - if (rwb->rhmaxblocks > 0) + allocsize = rwb->rhmaxblocks * rwb->blocksize; + rwb->rhbuffer = kmm_malloc(allocsize); + if (!rwb->rhbuffer) { - allocsize = rwb->rhmaxblocks * rwb->blocksize; - rwb->rhbuffer = kmm_malloc(allocsize); - if (!rwb->rhbuffer) - { - ferr("Read-ahead buffer kmm_malloc(%d) failed\n", allocsize); - return -ENOMEM; - } + ferr("Read-ahead buffer kmm_malloc(%d) failed\n", allocsize); + return -ENOMEM; } finfo("Read-ahead buffer size: %d bytes\n", allocsize);