From b4511e39fd60f6215acc78525c2b29d41c0a0d1c Mon Sep 17 00:00:00 2001 From: Ziye Yang Date: Fri, 4 Aug 2017 13:53:51 +0800 Subject: [PATCH] blobfs: Remove unnecessary if statement. Change-Id: I9134ffcb9713e0613de61d3178940390291dc287 Signed-off-by: Ziye Yang Reviewed-on: https://review.gerrithub.io/372621 Tested-by: SPDK Automated Test System Reviewed-by: Daniel Verkamp Reviewed-by: Jim Harris --- lib/blobfs/blobfs.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/lib/blobfs/blobfs.c b/lib/blobfs/blobfs.c index 3be3108e9..4698c76a4 100644 --- a/lib/blobfs/blobfs.c +++ b/lib/blobfs/blobfs.c @@ -1604,23 +1604,21 @@ cache_insert_buffer(struct spdk_file *file, uint64_t offset) } buf->buf = alloc_cache_memory_buffer(file); - if (buf->buf == NULL) { - while (buf->buf == NULL) { - /* - * TODO: alloc_cache_memory_buffer() should eventually free - * some buffers. Need a more sophisticated check here, instead - * of just bailing if 100 tries does not result in getting a - * free buffer. This will involve using the sync channel's - * semaphore to block until a buffer becomes available. - */ - if (count++ == 100) { - SPDK_ERRLOG("could not allocate cache buffer\n"); - assert(false); - free(buf); - return NULL; - } - buf->buf = alloc_cache_memory_buffer(file); + while (buf->buf == NULL) { + /* + * TODO: alloc_cache_memory_buffer() should eventually free + * some buffers. Need a more sophisticated check here, instead + * of just bailing if 100 tries does not result in getting a + * free buffer. This will involve using the sync channel's + * semaphore to block until a buffer becomes available. + */ + if (count++ == 100) { + SPDK_ERRLOG("could not allocate cache buffer\n"); + assert(false); + free(buf); + return NULL; } + buf->buf = alloc_cache_memory_buffer(file); } buf->buf_size = CACHE_BUFFER_SIZE;