DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] app/testpmd: fix unchecked return value
@ 2021-03-16  4:55 Kalesh A P
  2021-03-16  5:43 ` Li, Xiaoyun
  2021-03-16  6:51 ` Kalesh A P
  0 siblings, 2 replies; 7+ messages in thread
From: Kalesh A P @ 2021-03-16  4:55 UTC (permalink / raw)
  To: dev; +Cc: xiaoyun.li, ferruh.yigit

From: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>

CID 353629 (#1 of 1): Unchecked return value (CHECKED_RETURN)
check_return: Calling rte_eth_dev_info_get without checking
return value (as is done elsewhere 110 out of 117 times).

Coverity issue: 353629

Fixes: e1d44d0ad623 ("app/testpmd: show MAC addresses added to a port")
Cc: stable@dpdk.org

Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
---
 app/test-pmd/config.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 576d5ac..ade26e0 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -4927,10 +4927,15 @@ show_macs(portid_t port_id)
 	struct rte_ether_addr *addr;
 	uint32_t i, num_macs = 0;
 	struct rte_eth_dev *dev;
+	int ret;
 
 	dev = &rte_eth_devices[port_id];
 
-	rte_eth_dev_info_get(port_id, &dev_info);
+	ret = rte_eth_dev_info_get(port_id, &dev_info);
+	if (ret != 0) {
+		printf("rte_eth_dev_info_get() failed for port %u\n", port_id);
+		return;
+	}
 
 	for (i = 0; i < dev_info.max_mac_addrs; i++) {
 		addr = &dev->data->mac_addrs[i];
-- 
2.10.1


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

* Re: [dpdk-dev] [PATCH] app/testpmd: fix unchecked return value
  2021-03-16  4:55 [dpdk-dev] [PATCH] app/testpmd: fix unchecked return value Kalesh A P
@ 2021-03-16  5:43 ` Li, Xiaoyun
  2021-03-16  6:31   ` Kalesh Anakkur Purayil
  2021-03-16  6:51 ` Kalesh A P
  1 sibling, 1 reply; 7+ messages in thread
From: Li, Xiaoyun @ 2021-03-16  5:43 UTC (permalink / raw)
  To: Kalesh A P, dev; +Cc: Yigit, Ferruh

Hi

> -----Original Message-----
> From: Kalesh A P <kalesh-anakkur.purayil@broadcom.com>
> Sent: Tuesday, March 16, 2021 12:55
> To: dev@dpdk.org
> Cc: Li, Xiaoyun <xiaoyun.li@intel.com>; Yigit, Ferruh <ferruh.yigit@intel.com>
> Subject: [dpdk-dev] [PATCH] app/testpmd: fix unchecked return value
> 
> From: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
> 
> CID 353629 (#1 of 1): Unchecked return value (CHECKED_RETURN)
> check_return: Calling rte_eth_dev_info_get without checking return value (as is
> done elsewhere 110 out of 117 times).

You can just say "This patch checks return value for rte_eth_dev_info_get() in show_macs()."

> 
> Coverity issue: 353629
> 
No need for this breaking line. Please see other examples for Coverity issues.

> Fixes: e1d44d0ad623 ("app/testpmd: show MAC addresses added to a port")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
> ---
>  app/test-pmd/config.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index
> 576d5ac..ade26e0 100644
> --- a/app/test-pmd/config.c
> +++ b/app/test-pmd/config.c
> @@ -4927,10 +4927,15 @@ show_macs(portid_t port_id)
>  	struct rte_ether_addr *addr;
>  	uint32_t i, num_macs = 0;
>  	struct rte_eth_dev *dev;
> +	int ret;
> 
>  	dev = &rte_eth_devices[port_id];
> 
> -	rte_eth_dev_info_get(port_id, &dev_info);
> +	ret = rte_eth_dev_info_get(port_id, &dev_info);
> +	if (ret != 0) {
> +		printf("rte_eth_dev_info_get() failed for port %u\n", port_id);
> +		return;
> +	}

You can use eth_dev_info_get_print_err(). Testpmd uses this function to unify the err print. And only this place needs check, so you don't need to define "ret".
Just the following is enough:

if (eth_dev_info_get_print_err(port_id, &dev_info))
          return;

BRs
Xiaoyun
> 
>  	for (i = 0; i < dev_info.max_mac_addrs; i++) {
>  		addr = &dev->data->mac_addrs[i];
> --
> 2.10.1


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

* Re: [dpdk-dev] [PATCH] app/testpmd: fix unchecked return value
  2021-03-16  5:43 ` Li, Xiaoyun
@ 2021-03-16  6:31   ` Kalesh Anakkur Purayil
  0 siblings, 0 replies; 7+ messages in thread
From: Kalesh Anakkur Purayil @ 2021-03-16  6:31 UTC (permalink / raw)
  To: Li, Xiaoyun; +Cc: dev, Yigit, Ferruh

[-- Attachment #1: Type: text/plain, Size: 2348 bytes --]

Hi Xiaoyun,

Thank you for the suggestion. I have sent the updated patch.

Regards,
Kalesh

On Tue, Mar 16, 2021 at 11:13 AM Li, Xiaoyun <xiaoyun.li@intel.com> wrote:

> Hi
>
> > -----Original Message-----
> > From: Kalesh A P <kalesh-anakkur.purayil@broadcom.com>
> > Sent: Tuesday, March 16, 2021 12:55
> > To: dev@dpdk.org
> > Cc: Li, Xiaoyun <xiaoyun.li@intel.com>; Yigit, Ferruh <
> ferruh.yigit@intel.com>
> > Subject: [dpdk-dev] [PATCH] app/testpmd: fix unchecked return value
> >
> > From: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
> >
> > CID 353629 (#1 of 1): Unchecked return value (CHECKED_RETURN)
> > check_return: Calling rte_eth_dev_info_get without checking return value
> (as is
> > done elsewhere 110 out of 117 times).
>
> You can just say "This patch checks return value for
> rte_eth_dev_info_get() in show_macs()."
>
> >
> > Coverity issue: 353629
> >
> No need for this breaking line. Please see other examples for Coverity
> issues.
>
> > Fixes: e1d44d0ad623 ("app/testpmd: show MAC addresses added to a port")
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
> > ---
> >  app/test-pmd/config.c | 7 ++++++-
> >  1 file changed, 6 insertions(+), 1 deletion(-)
> >
> > diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index
> > 576d5ac..ade26e0 100644
> > --- a/app/test-pmd/config.c
> > +++ b/app/test-pmd/config.c
> > @@ -4927,10 +4927,15 @@ show_macs(portid_t port_id)
> >       struct rte_ether_addr *addr;
> >       uint32_t i, num_macs = 0;
> >       struct rte_eth_dev *dev;
> > +     int ret;
> >
> >       dev = &rte_eth_devices[port_id];
> >
> > -     rte_eth_dev_info_get(port_id, &dev_info);
> > +     ret = rte_eth_dev_info_get(port_id, &dev_info);
> > +     if (ret != 0) {
> > +             printf("rte_eth_dev_info_get() failed for port %u\n",
> port_id);
> > +             return;
> > +     }
>
> You can use eth_dev_info_get_print_err(). Testpmd uses this function to
> unify the err print. And only this place needs check, so you don't need to
> define "ret".
> Just the following is enough:
>
> if (eth_dev_info_get_print_err(port_id, &dev_info))
>           return;
>
> BRs
> Xiaoyun
> >
> >       for (i = 0; i < dev_info.max_mac_addrs; i++) {
> >               addr = &dev->data->mac_addrs[i];
> > --
> > 2.10.1
>
>

-- 
Regards,
Kalesh A P

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

* Re: [dpdk-dev] [PATCH] app/testpmd: fix unchecked return value
  2021-03-16  6:51 ` Kalesh A P
@ 2021-03-16  6:34   ` Li, Xiaoyun
  2021-03-16  7:27     ` Andrew Rybchenko
  0 siblings, 1 reply; 7+ messages in thread
From: Li, Xiaoyun @ 2021-03-16  6:34 UTC (permalink / raw)
  To: Kalesh A P, dev; +Cc: Yigit, Ferruh

> -----Original Message-----
> From: Kalesh A P <kalesh-anakkur.purayil@broadcom.com>
> Sent: Tuesday, March 16, 2021 14:52
> To: dev@dpdk.org
> Cc: Li, Xiaoyun <xiaoyun.li@intel.com>; Yigit, Ferruh <ferruh.yigit@intel.com>
> Subject: [dpdk-dev] [PATCH] app/testpmd: fix unchecked return value
> 
> From: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
> 
> This patch checks return value for rte_eth_dev_info_get() in show_macs().
> 
> Coverity issue: 353629
> Fixes: e1d44d0ad623 ("app/testpmd: show MAC addresses added to a port")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
> ---
>  app/test-pmd/config.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index
> 576d5ac..4ce75a8 100644
> --- a/app/test-pmd/config.c
> +++ b/app/test-pmd/config.c
> @@ -4930,7 +4930,8 @@ show_macs(portid_t port_id)
> 
>  	dev = &rte_eth_devices[port_id];
> 
> -	rte_eth_dev_info_get(port_id, &dev_info);
> +	if (eth_dev_info_get_print_err(port_id, &dev_info))
> +		return;
> 
>  	for (i = 0; i < dev_info.max_mac_addrs; i++) {
>  		addr = &dev->data->mac_addrs[i];
> --
> 2.10.1

Acked-by: Xiaoyun Li <xiaoyun.li@intel.com>


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

* [dpdk-dev] [PATCH] app/testpmd: fix unchecked return value
  2021-03-16  4:55 [dpdk-dev] [PATCH] app/testpmd: fix unchecked return value Kalesh A P
  2021-03-16  5:43 ` Li, Xiaoyun
@ 2021-03-16  6:51 ` Kalesh A P
  2021-03-16  6:34   ` Li, Xiaoyun
  1 sibling, 1 reply; 7+ messages in thread
From: Kalesh A P @ 2021-03-16  6:51 UTC (permalink / raw)
  To: dev; +Cc: xiaoyun.li, ferruh.yigit

From: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>

This patch checks return value for rte_eth_dev_info_get() in show_macs().

Coverity issue: 353629
Fixes: e1d44d0ad623 ("app/testpmd: show MAC addresses added to a port")
Cc: stable@dpdk.org

Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
---
 app/test-pmd/config.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 576d5ac..4ce75a8 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -4930,7 +4930,8 @@ show_macs(portid_t port_id)
 
 	dev = &rte_eth_devices[port_id];
 
-	rte_eth_dev_info_get(port_id, &dev_info);
+	if (eth_dev_info_get_print_err(port_id, &dev_info))
+		return;
 
 	for (i = 0; i < dev_info.max_mac_addrs; i++) {
 		addr = &dev->data->mac_addrs[i];
-- 
2.10.1


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

* Re: [dpdk-dev] [PATCH] app/testpmd: fix unchecked return value
  2021-03-16  6:34   ` Li, Xiaoyun
@ 2021-03-16  7:27     ` Andrew Rybchenko
  2021-03-16 10:18       ` Ferruh Yigit
  0 siblings, 1 reply; 7+ messages in thread
From: Andrew Rybchenko @ 2021-03-16  7:27 UTC (permalink / raw)
  To: Li, Xiaoyun, Kalesh A P, dev; +Cc: Yigit, Ferruh

On 3/16/21 9:34 AM, Li, Xiaoyun wrote:
>> -----Original Message-----
>> From: Kalesh A P <kalesh-anakkur.purayil@broadcom.com>
>> Sent: Tuesday, March 16, 2021 14:52
>> To: dev@dpdk.org
>> Cc: Li, Xiaoyun <xiaoyun.li@intel.com>; Yigit, Ferruh <ferruh.yigit@intel.com>
>> Subject: [dpdk-dev] [PATCH] app/testpmd: fix unchecked return value
>>
>> From: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
>>
>> This patch checks return value for rte_eth_dev_info_get() in show_macs().
>>
>> Coverity issue: 353629
>> Fixes: e1d44d0ad623 ("app/testpmd: show MAC addresses added to a port")
>> Cc: stable@dpdk.org
>>
>> Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
>> ---
>>  app/test-pmd/config.c | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index
>> 576d5ac..4ce75a8 100644
>> --- a/app/test-pmd/config.c
>> +++ b/app/test-pmd/config.c
>> @@ -4930,7 +4930,8 @@ show_macs(portid_t port_id)
>>
>>  	dev = &rte_eth_devices[port_id];
>>
>> -	rte_eth_dev_info_get(port_id, &dev_info);
>> +	if (eth_dev_info_get_print_err(port_id, &dev_info))
>> +		return;
>>
>>  	for (i = 0; i < dev_info.max_mac_addrs; i++) {
>>  		addr = &dev->data->mac_addrs[i];
>> --
>> 2.10.1
> 
> Acked-by: Xiaoyun Li <xiaoyun.li@intel.com>
> 

Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>


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

* Re: [dpdk-dev] [PATCH] app/testpmd: fix unchecked return value
  2021-03-16  7:27     ` Andrew Rybchenko
@ 2021-03-16 10:18       ` Ferruh Yigit
  0 siblings, 0 replies; 7+ messages in thread
From: Ferruh Yigit @ 2021-03-16 10:18 UTC (permalink / raw)
  To: Andrew Rybchenko, Li, Xiaoyun, Kalesh A P, dev

On 3/16/2021 7:27 AM, Andrew Rybchenko wrote:
> On 3/16/21 9:34 AM, Li, Xiaoyun wrote:
>>> -----Original Message-----
>>> From: Kalesh A P <kalesh-anakkur.purayil@broadcom.com>
>>> Sent: Tuesday, March 16, 2021 14:52
>>> To: dev@dpdk.org
>>> Cc: Li, Xiaoyun <xiaoyun.li@intel.com>; Yigit, Ferruh <ferruh.yigit@intel.com>
>>> Subject: [dpdk-dev] [PATCH] app/testpmd: fix unchecked return value
>>>
>>> From: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
>>>
>>> This patch checks return value for rte_eth_dev_info_get() in show_macs().
>>>
>>> Coverity issue: 353629
>>> Fixes: e1d44d0ad623 ("app/testpmd: show MAC addresses added to a port")
>>> Cc: stable@dpdk.org
>>>
>>> Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
>>> ---
>>>   app/test-pmd/config.c | 3 ++-
>>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index
>>> 576d5ac..4ce75a8 100644
>>> --- a/app/test-pmd/config.c
>>> +++ b/app/test-pmd/config.c
>>> @@ -4930,7 +4930,8 @@ show_macs(portid_t port_id)
>>>
>>>   	dev = &rte_eth_devices[port_id];
>>>
>>> -	rte_eth_dev_info_get(port_id, &dev_info);
>>> +	if (eth_dev_info_get_print_err(port_id, &dev_info))
>>> +		return;
>>>
>>>   	for (i = 0; i < dev_info.max_mac_addrs; i++) {
>>>   		addr = &dev->data->mac_addrs[i];
>>> --
>>> 2.10.1
>>
>> Acked-by: Xiaoyun Li <xiaoyun.li@intel.com>
>>
> 
> Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
> 

Applied to dpdk-next-net/main, thanks.

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

end of thread, other threads:[~2021-03-16 10:18 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-16  4:55 [dpdk-dev] [PATCH] app/testpmd: fix unchecked return value Kalesh A P
2021-03-16  5:43 ` Li, Xiaoyun
2021-03-16  6:31   ` Kalesh Anakkur Purayil
2021-03-16  6:51 ` Kalesh A P
2021-03-16  6:34   ` Li, Xiaoyun
2021-03-16  7:27     ` Andrew Rybchenko
2021-03-16 10:18       ` Ferruh Yigit

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).