bdev/aio: Improve error check of config file parsing by spdk_strtol
Change-Id: I6e0657c22a124e5c8773f27d40c8cdf7b35055d8 Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-on: https://review.gerrithub.io/c/441638 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com> Reviewed-by: wuzhouhui <wuzhouhui@kingsoft.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
This commit is contained in:
parent
67b720f451
commit
889abac05d
@ -686,6 +686,7 @@ bdev_aio_initialize(void)
|
|||||||
const char *name;
|
const char *name;
|
||||||
const char *block_size_str;
|
const char *block_size_str;
|
||||||
uint32_t block_size = 0;
|
uint32_t block_size = 0;
|
||||||
|
long int tmp;
|
||||||
|
|
||||||
file = spdk_conf_section_get_nmval(sp, "AIO", i, 0);
|
file = spdk_conf_section_get_nmval(sp, "AIO", i, 0);
|
||||||
if (!file) {
|
if (!file) {
|
||||||
@ -701,7 +702,13 @@ bdev_aio_initialize(void)
|
|||||||
|
|
||||||
block_size_str = spdk_conf_section_get_nmval(sp, "AIO", i, 2);
|
block_size_str = spdk_conf_section_get_nmval(sp, "AIO", i, 2);
|
||||||
if (block_size_str) {
|
if (block_size_str) {
|
||||||
block_size = atoi(block_size_str);
|
tmp = spdk_strtol(block_size_str, 10);
|
||||||
|
if (tmp < 0) {
|
||||||
|
SPDK_ERRLOG("Invalid block size for AIO disk with file %s\n", file);
|
||||||
|
i++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
block_size = (uint32_t)tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
bdev = create_aio_disk(name, file, block_size);
|
bdev = create_aio_disk(name, file, block_size);
|
||||||
|
Loading…
Reference in New Issue
Block a user