[dpdk-dev] [dpdk-dev,1/2] ethdev: remove useless null checks
Thomas Monjalon
thomas.monjalon at 6wind.com
Fri Jan 22 10:11:47 CET 2016
2016-01-21 20:02, Jan Viktorin:
> On Thu, 21 Jan 2016 12:57:10 +0100
> David Marchand <david.marchand at 6wind.com> wrote:
> > - if ((name == NULL) || (pci_dev == NULL))
> > - return -EINVAL;
>
> Do you use a kind of assert in DPDK? The patch looks OK, however, I
> would prefer something like
>
> assert_not_null(name);
> assert_not_null(pci_dev);
>
> Usually, if some outer code is broken by mistake, the assert catches
> such an issue. At the same time, it documents the code by telling
> "this must never be NULL here". I agree, that returning -EINVAL for
> this kind of check is incorrect.
>
> Same for other changes...
For this patch, I agree to remove useless checks.
For the other checks, EINVAL seems to be the right error code.
And yes you are right, we could replace most of EINVAL returns by a kind
of assert. RTE_VERIFY would be appropriate.
More information about the dev
mailing list