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 <gang.cao@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/3236
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Xiaodong Liu <xiaodong.liu@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
GangCao 2020-07-07 17:43:17 -04:00 committed by Tomasz Zawadzki
parent 4c9aad0299
commit 249f95daeb

View File

@ -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;
}
}