From 249f95daebf0f3e0a6e92371cb7b9e6ee41f6774 Mon Sep 17 00:00:00 2001 From: GangCao Date: Tue, 7 Jul 2020 17:43:17 -0400 Subject: [PATCH] BlobFS: fix the case where configuration field is not set In the case that the configuration field is not set, it will return "-1" and then implicitly convert to the unsigned case where the variable is wrongly set. Change-Id: I7b2c64d653badd731d8e6df46629231343a0ae6d Signed-off-by: GangCao Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/3236 Reviewed-by: Changpeng Liu Reviewed-by: Xiaodong Liu Reviewed-by: Tomasz Zawadzki Reviewed-by: Shuhei Matsumoto Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins --- lib/blobfs/blobfs.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/blobfs/blobfs.c b/lib/blobfs/blobfs.c index 96992b624..f46dd3ea3 100644 --- a/lib/blobfs/blobfs.c +++ b/lib/blobfs/blobfs.c @@ -554,6 +554,7 @@ static void fs_conf_parse(void) { struct spdk_conf_section *sp; + int cache_buffer_shift; sp = spdk_conf_find_section(NULL, "Blobfs"); if (sp == NULL) { @@ -561,9 +562,11 @@ fs_conf_parse(void) return; } - g_fs_cache_buffer_shift = spdk_conf_section_get_intval(sp, "CacheBufferShift"); - if (g_fs_cache_buffer_shift <= 0) { + cache_buffer_shift = spdk_conf_section_get_intval(sp, "CacheBufferShift"); + if (cache_buffer_shift <= 0) { g_fs_cache_buffer_shift = CACHE_BUFFER_SHIFT_DEFAULT; + } else { + g_fs_cache_buffer_shift = cache_buffer_shift; } }