On Wed,  9 May 2018 11:43:32 +0200
Thomas Monjalon <tho...@monjalon.net> wrote:

> -     RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
> +     if (port_id >= RTE_MAX_ETHPORTS || ethdev->data->name[0] == '\0') {

Since name being empty now has significance, why not introduce an macro or 
inline function
to make the test. Also, static checkers don't like pointers which maybe outside 
valid
range (sometimes).

static inline bool rte_ethdev_is_unused(const struct rte_ethdev *ethdev)
{
        return ethdev->data->name[0] == '\0';
}

#define RTE_ETH_UNUSED_OR_ERR_RET(ethdev, retval)  do { \
        if (!rte_ethdev_is_unused(ethdev)) { \
                RTE_PMD_DEBUG_TRACE("Port already in use=%d\n", 
ethdev->port_id); \
                return retval; \
        } } while(0)


        

Reply via email to