[dpdk-dev] [PATCH v4 1/4] mempool: add event callbacks
Dmitry Kozlyuk
dkozlyuk at oss.nvidia.com
Fri Oct 15 11:13:31 CEST 2021
> -----Original Message-----
> From: Andrew Rybchenko <andrew.rybchenko at oktetlabs.ru>
> [...]
> With below review notes processed
>
> Reviewed-by: Andrew Rybchenko <andrew.rybchenko at oktetlabs.ru>
>
Thanks for the comments, I'll fix them all, just a small note below FYI.
> > + rte_mcfg_mempool_read_lock();
> > + rte_mcfg_tailq_write_lock();
> > + ret = -ENOENT;
> > + list = RTE_TAILQ_CAST(callback_tailq.head, mempool_callback_list);
> > + TAILQ_FOREACH(te, list, next) {
> > + cb = (struct mempool_callback *)te->data;
> > + if (cb->func == func && cb->user_data == user_data)
> > + break;
> > + }
> > + if (te != NULL) {
>
> Here we rely on the fact that TAILQ_FOREACH() exists with te==NULL in the
> case of no such entry. I'd suggest to avoid the assumption.
> I.e. do below two lines above before break and have not the if condition
> her at all.
Since you asked the question, the code is non-obvious, so I'll change it.
FWIW, man 3 tailq:
TAILQ_FOREACH() traverses the queue referenced by head in the forward
direction, assigning each element in turn to var. var is set to NULL
if the loop completes normally, or if there were no elements.
More information about the dev
mailing list