nvme_manage: move ndata to a local variable

This doesn't need to be stored in the device struct, since it is only
used within ns_manage_add(), and it is freed at the end of the function.

Change-Id: If725408026736d4ef9a0695ab28bc30e6648932e
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
Daniel Verkamp 2016-03-04 13:51:46 -07:00
parent eb9ef5cc2b
commit c015a2485b

View File

@ -50,7 +50,6 @@ struct rte_mempool *request_mempool;
struct dev {
struct spdk_pci_device *pci_dev;
struct spdk_nvme_ctrlr *ctrlr;
struct spdk_nvme_ns_data *ndata;
const struct spdk_nvme_ctrlr_data *cdata;
struct spdk_nvme_ctrlr_list *ctrlr_list;
};
@ -133,22 +132,23 @@ static void
ns_manage_add(struct dev *device, uint64_t ns_size, uint64_t ns_capacity, int ns_lbasize)
{
int ret = 0;
struct spdk_nvme_ns_data *ndata;
device->ndata = rte_zmalloc("nvme namespace data", sizeof(struct spdk_nvme_ns_data), 4096);
if (device->ndata == NULL) {
ndata = rte_zmalloc("nvme namespace data", sizeof(struct spdk_nvme_ns_data), 4096);
if (ndata == NULL) {
printf("Allocation error (namespace data)\n");
exit(1);
}
device->ndata->nsze = ns_size;
device->ndata->ncap = ns_capacity;
device->ndata->flbas.format = ns_lbasize;
ret = spdk_nvme_ctrlr_create_ns(device->ctrlr, device->ndata);
ndata->nsze = ns_size;
ndata->ncap = ns_capacity;
ndata->flbas.format = ns_lbasize;
ret = spdk_nvme_ctrlr_create_ns(device->ctrlr, ndata);
if (ret) {
fprintf(stdout, "ns manage: Failed\n");
}
rte_free(device->ndata);
rte_free(ndata);
}
static void