From addb8110f2225b7d763d83036c5328a2095c2848 Mon Sep 17 00:00:00 2001 From: yidong0635 Date: Wed, 31 Oct 2018 11:48:25 -0400 Subject: [PATCH] nvmf: change the return type of calloc failed 1.nvmf: change the return type of calloc failed to -ENOMEM and keep consistency in this file. 2.thread: revise rc condition to ( rc!= 0),to deal with all abnormal return. Change-Id: I7cccb548f30448eaa1bac1a5904c3edcad9c1208 Signed-off-by: yidong0635 Reviewed-on: https://review.gerrithub.io/431459 (master) Reviewed-on: https://review.gerrithub.io/436858 Tested-by: SPDK CI Jenkins Reviewed-by: Shuhei Matsumoto Reviewed-by: Jim Harris Chandler-Test-Pool: SPDK Automated Test System --- lib/nvmf/nvmf.c | 2 +- lib/thread/thread.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/nvmf/nvmf.c b/lib/nvmf/nvmf.c index 9ff9f31f3..af03c0064 100644 --- a/lib/nvmf/nvmf.c +++ b/lib/nvmf/nvmf.c @@ -139,7 +139,7 @@ spdk_nvmf_tgt_create_poll_group(void *io_device, void *ctx_buf) group->num_sgroups = tgt->opts.max_subsystems; group->sgroups = calloc(tgt->opts.max_subsystems, sizeof(struct spdk_nvmf_subsystem_poll_group)); if (!group->sgroups) { - return -1; + return -ENOMEM; } for (sid = 0; sid < tgt->opts.max_subsystems; sid++) { diff --git a/lib/thread/thread.c b/lib/thread/thread.c index c014f4ed0..3f0257689 100644 --- a/lib/thread/thread.c +++ b/lib/thread/thread.c @@ -530,7 +530,7 @@ spdk_get_io_channel(void *io_device) pthread_mutex_unlock(&g_devlist_mutex); rc = dev->create_cb(io_device, (uint8_t *)ch + sizeof(*ch)); - if (rc == -1) { + if (rc != 0) { pthread_mutex_lock(&g_devlist_mutex); TAILQ_REMOVE(&ch->thread->io_channels, ch, tailq); dev->refcnt--;