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 <changpeng.liu@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/463480
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
Changpeng Liu 2019-07-29 03:31:52 -04:00 committed by Ben Walker
parent 5de38f9543
commit 0d9279c596

View File

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