nvme: fix the parse of spdk_nvme_transport_id_parse
Normally, there will be only one separator in transport id, for example, either ':' or '='. But the users may input this: trtype=PCIe traddr=0000:81:00.0. Thus, there will be two diffrent separator '=' and ':', and our function doest not handle this case correctly. And this patch can fix this issue, and also update the test case. Change-Id: Ic3f10dc1e37c66647fede37c5cf9523fc2652677 Signed-off-by: Ziye Yang <ziye.yang@intel.com> Reviewed-on: https://review.gerrithub.io/428307 Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
This commit is contained in:
parent
93ee8c7a7f
commit
5c9dccc962
@ -711,7 +711,7 @@ spdk_nvme_transport_id_adrfam_str(enum spdk_nvmf_adrfam adrfam)
|
||||
int
|
||||
spdk_nvme_transport_id_parse(struct spdk_nvme_transport_id *trid, const char *str)
|
||||
{
|
||||
const char *sep;
|
||||
const char *sep, *sep1;
|
||||
const char *whitespace = " \t\n";
|
||||
size_t key_len, val_len;
|
||||
char key[32];
|
||||
@ -731,6 +731,11 @@ spdk_nvme_transport_id_parse(struct spdk_nvme_transport_id *trid, const char *st
|
||||
SPDK_ERRLOG("Key without ':' or '=' separator\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
} else {
|
||||
sep1 = strchr(str, '=');
|
||||
if ((sep1 != NULL) && (sep1 < sep)) {
|
||||
sep = sep1;
|
||||
}
|
||||
}
|
||||
|
||||
key_len = sep - str;
|
||||
|
@ -913,6 +913,11 @@ test_trid_parse_and_compare(void)
|
||||
CU_ASSERT(spdk_nvme_transport_id_parse(&trid1, "trtype:PCIe traddr:0000:04:00.0") == 0);
|
||||
CU_ASSERT(spdk_nvme_transport_id_parse(&trid2, "trtype:PCIe traddr:05:00.0") == 0);
|
||||
CU_ASSERT(spdk_nvme_transport_id_compare(&trid1, &trid2) < 0);
|
||||
|
||||
memset_trid(&trid1, &trid2);
|
||||
CU_ASSERT(spdk_nvme_transport_id_parse(&trid1, "trtype=PCIe traddr=0000:04:00.0") == 0);
|
||||
CU_ASSERT(spdk_nvme_transport_id_parse(&trid2, "trtype=PCIe traddr=05:00.0") == 0);
|
||||
CU_ASSERT(spdk_nvme_transport_id_compare(&trid1, &trid2) < 0);
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user