DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] Questions about API with no parameter check
@ 2021-04-07 11:28 Min Hu (Connor)
  2021-04-07 11:40 ` Thomas Monjalon
  0 siblings, 1 reply; 18+ messages in thread
From: Min Hu (Connor) @ 2021-04-07 11:28 UTC (permalink / raw)
  To: dev, Ferruh Yigit, Andrew Rybchenko, Thomas Monjalon

Hi, all,
	Many APIs in DPDK does not check if the pointer parameter is
NULL or not. For example, in 'rte_ethdev.c':
int
rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
		       uint16_t nb_rx_desc, unsigned int socket_id,
		       const struct rte_eth_rxconf *rx_conf,
		       struct rte_mempool *mp)

int
rte_eth_link_get(uint16_t port_id, struct rte_eth_link *eth_link)

int
rte_eth_stats_get(uint16_t port_id, struct rte_eth_stats *stats)

int
rte_eth_dev_info_get(uint16_t port_id, struct rte_eth_dev_info *dev_info)

As these APIs could be used by any APPs, if the APP give NULL as
the pointer parameter, segmetation default will occur.

So, my question is, should we add check in the API? like that,
int rte_eth_stats_get(uint16_t port_id, struct rte_eth_stats *stats)
{
	if (stats == NULL)
		return -EINVAL;
	...
}

Or, that is redundant, the parameter correctness should be guaranteed by
the APP?

What's your opinion? Hope for your reply.
	Thanks.

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2021-05-05 15:58 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-07 11:28 [dpdk-dev] Questions about API with no parameter check Min Hu (Connor)
2021-04-07 11:40 ` Thomas Monjalon
2021-04-07 11:48   ` Liang Ma
2021-04-07 11:53   ` Ananyev, Konstantin
2021-04-07 13:19     ` Jerin Jacob
2021-04-07 14:40       ` Ajit Khaparde
2021-04-07 15:25         ` Hemant Agrawal
2021-04-07 16:10           ` Ferruh Yigit
2021-04-07 16:26             ` Burakov, Anatoly
2021-04-08  1:06               ` Min Hu (Connor)
2021-04-08  8:22                 ` Thomas Monjalon
2021-04-08  9:00                   ` Min Hu (Connor)
2021-04-29 16:16             ` Tyler Retzlaff
2021-04-29 18:49               ` Dmitry Kozlyuk
2021-04-30  0:15                 ` Tyler Retzlaff
2021-05-03 15:19                   ` Morten Brørup
2021-05-04  9:36                 ` Ananyev, Konstantin
2021-05-05 15:58                   ` Tyler Retzlaff

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).