From: Thomas Monjalon <thomas@monjalon.net>
To: Ferruh Yigit <ferruh.yigit@intel.com>
Cc: Andrew Rybchenko <arybchenko@solarflare.com>,
dev@dpdk.org, Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Subject: Re: [dpdk-dev] [PATCH] ethdev: unify error code if port ID is invalid
Date: Sat, 17 Oct 2020 11:22:30 +0200 [thread overview]
Message-ID: <1837298.Gbl8trm7sQ@thomas> (raw)
In-Reply-To: <2abbae70-2e07-23f0-df4a-51d475d24164@intel.com>
17/10/2020 01:43, Ferruh Yigit:
> On 10/16/2020 10:58 PM, Ferruh Yigit wrote:
> > On 10/16/2020 1:05 PM, Ferruh Yigit wrote:
> >> On 10/13/2020 4:32 PM, Ferruh Yigit wrote:
> >>> On 10/13/2020 3:53 PM, Andrew Rybchenko wrote:
> >>>> Use ENODEV as the error code if specified port ID is invalid.
> >>>>
> >>>> Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
> >>>> ---
> >>>> lib/librte_ethdev/rte_ethdev.c | 44 ++++++++++++++++----------------
> >>>> lib/librte_ethdev/rte_ethdev.h | 46 +++++++++++++++++++++++-----------
> >>>> 2 files changed, 54 insertions(+), 36 deletions(-)
> >>>>
> >>>> diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c
> >>>> index 5b7979a3b8..1f862f918a 100644
> >>>> --- a/lib/librte_ethdev/rte_ethdev.c
> >>>> +++ b/lib/librte_ethdev/rte_ethdev.c
> >>>> @@ -784,7 +784,7 @@ rte_eth_dev_get_name_by_port(uint16_t port_id, char *name)
> >>>> {
> >>>> char *tmp;
> >>>> - RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
> >>>> + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
> >>>
> >>> Thanks Andrew, +1 to this error unification.
> >>>
> >>> This will be API change without deprecation notice, cc'ed techboard for it.
> >>>
> >>> If this should (almost) always return '-ENODEV', does it make sense to make
> >>> another wrapper macro for it, to prevent later other error types used again.
> >>>
> >>> And there are a few instances returning '-1', are they left intentionally?
> >>>
> >>
> >> Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
> > >
> >
> > Applied to dpdk-next-net/main, thanks.
> >
>
> There are some bitratestats unit tests, that checks APIs with invalid port_id.
> Unit tests checks return values as '-EINVAL', they also should be updated as
> '-ENODEV' with this patch.
>
> Adding following update to this patch in next-net
>
> diff --git a/app/test/test_bitratestats.c b/app/test/test_bitratestats.c
> index 39d7f734d4..fb4203c57b 100644
> --- a/app/test/test_bitratestats.c
> +++ b/app/test/test_bitratestats.c
> @@ -99,8 +99,8 @@ test_stats_bitrate_calc_invalid_portid_1(void)
> int ret = 0;
>
> ret = rte_stats_bitrate_calc(bitrate_data, 33);
> - TEST_ASSERT(ret == -EINVAL, "Test Failed: Expected -%d for higher "
> - "portid rte_stats_bitrate_calc ret:%d", EINVAL, ret);
> + TEST_ASSERT(ret == -ENODEV, "Test Failed: Expected -%d for higher "
> + "portid rte_stats_bitrate_calc ret:%d", ENODEV, ret);
>
> return TEST_SUCCESS;
> }
> @@ -112,8 +112,8 @@ test_stats_bitrate_calc_invalid_portid_2(void)
> int ret = 0;
>
> ret = rte_stats_bitrate_calc(bitrate_data, -1);
> - TEST_ASSERT(ret == -EINVAL, "Test Failed: Expected -%d for invalid "
> - "portid rte_stats_bitrate_calc ret:%d", EINVAL, ret);
> + TEST_ASSERT(ret == -ENODEV, "Test Failed: Expected -%d for invalid "
> + "portid rte_stats_bitrate_calc ret:%d", ENODEV, ret);
>
> return TEST_SUCCESS;
> }
> @@ -125,9 +125,9 @@ test_stats_bitrate_calc_non_existing_portid(void)
> int ret = 0;
>
> ret = rte_stats_bitrate_calc(bitrate_data, 31);
> - TEST_ASSERT(ret == -EINVAL, "Test Failed: Expected -%d for "
> + TEST_ASSERT(ret == -ENODEV, "Test Failed: Expected -%d for "
> "non-existing portid rte_stats_bitrate_calc ret:%d",
> - EINVAL, ret);
> + ENODEV, ret);
>
> return TEST_SUCCESS;
> }
Thank you Ferruh for the extra checks.
prev parent reply other threads:[~2020-10-17 9:22 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-13 14:53 Andrew Rybchenko
2020-10-13 15:32 ` Ferruh Yigit
2020-10-13 15:39 ` Andrew Rybchenko
2020-10-13 16:12 ` Ferruh Yigit
2020-10-14 6:16 ` Andrew Rybchenko
2020-10-14 16:01 ` Ferruh Yigit
2020-10-13 15:47 ` Thomas Monjalon
2020-10-16 12:05 ` Ferruh Yigit
2020-10-16 21:58 ` Ferruh Yigit
2020-10-16 23:43 ` Ferruh Yigit
2020-10-17 9:22 ` Thomas Monjalon [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1837298.Gbl8trm7sQ@thomas \
--to=thomas@monjalon.net \
--cc=andrew.rybchenko@oktetlabs.ru \
--cc=arybchenko@solarflare.com \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).