From 0d9279c59633b8fcfb3cb08f60af68f004a86dc3 Mon Sep 17 00:00:00 2001 From: Changpeng Liu Date: Mon, 29 Jul 2019 03:31:52 -0400 Subject: [PATCH] examples/nvme/identify: set features valid flag to false before getting new value features are global variable and can be used for different controllers, e.g: there are 2 controllers, the first one can support Arbitration feature, and the second controller can't support Arbitration feature, the value from features[fid].valid may contain the first drive's old value. Change-Id: If020a0413a8a32e2be25ecccb5baf0a82d99371b Signed-off-by: Changpeng Liu Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/463480 Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris Reviewed-by: Ben Walker --- examples/nvme/identify/identify.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/examples/nvme/identify/identify.c b/examples/nvme/identify/identify.c index 632513e6b..8c70bafc7 100644 --- a/examples/nvme/identify/identify.c +++ b/examples/nvme/identify/identify.c @@ -57,7 +57,7 @@ struct feature { bool valid; }; -static struct feature features[256]; +static struct feature features[256] = {}; static struct spdk_nvme_error_information_entry error_page[256]; @@ -180,11 +180,14 @@ static int get_feature(struct spdk_nvme_ctrlr *ctrlr, uint8_t fid) { struct spdk_nvme_cmd cmd = {}; + struct feature *feature = &features[fid]; + + feature->valid = false; cmd.opc = SPDK_NVME_OPC_GET_FEATURES; cmd.cdw10 = fid; - return spdk_nvme_ctrlr_cmd_admin_raw(ctrlr, &cmd, NULL, 0, get_feature_completion, &features[fid]); + return spdk_nvme_ctrlr_cmd_admin_raw(ctrlr, &cmd, NULL, 0, get_feature_completion, feature); } static void