Hi David, Sorry for multiple mails on a patch. I forgot a trivial comment in previous mail.
> -----Original Message----- > From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of David Hunt > Sent: Friday, June 03, 2016 8:28 PM > To: dev at dpdk.org > Cc: olivier.matz at 6wind.com; viktorin at rehivetech.com; > jerin.jacob at caviumnetworks.com; David Hunt <david.hunt at intel.com> > Subject: [dpdk-dev] [PATCH v8 1/3] mempool: support external mempool > operations > [...] > +int > +rte_mempool_ops_register(const struct rte_mempool_ops *h) > +{ > + struct rte_mempool_ops *ops; > + int16_t ops_index; > + > + rte_spinlock_lock(&rte_mempool_ops_table.sl); > + > + if (rte_mempool_ops_table.num_ops >= > + RTE_MEMPOOL_MAX_OPS_IDX) { > + rte_spinlock_unlock(&rte_mempool_ops_table.sl); > + RTE_LOG(ERR, MEMPOOL, > + "Maximum number of mempool ops structs exceeded\n"); > + return -ENOSPC; > + } > + > + if (h->put == NULL || h->get == NULL || h->get_count == NULL) { I think 'h->alloc' should also be checked here. > + rte_spinlock_unlock(&rte_mempool_ops_table.sl); > + RTE_LOG(ERR, MEMPOOL, > + "Missing callback while registering mempool ops\n"); > + return -EINVAL; > + } > + > + if (strlen(h->name) >= sizeof(ops->name) - 1) { > + RTE_LOG(DEBUG, EAL, "%s(): mempool_ops <%s>: name too long\n", > + __func__, h->name); > + rte_errno = EEXIST; > + return NULL; > + } > + > + ops_index = rte_mempool_ops_table.num_ops++; > + ops = &rte_mempool_ops_table.ops[ops_index]; > + snprintf(ops->name, sizeof(ops->name), "%s", h->name); > + ops->alloc = h->alloc; > + ops->put = h->put; > + ops->get = h->get; > + ops->get_count = h->get_count; > + > + rte_spinlock_unlock(&rte_mempool_ops_table.sl); > + > + return ops_index; > +} > + [...] - Shreyansh