[dpdk-dev] [PATCH] app/testpmd: fix passing negative parameter to strerror
Kevin Traynor
ktraynor at redhat.com
Thu Jun 4 12:51:42 CEST 2020
On 04/06/2020 09:45, Phil Yang wrote:
>> -----Original Message-----
>> From: dev <dev-bounces at dpdk.org> On Behalf Of Wei Hu (Xavier)
>> Sent: Thursday, June 4, 2020 2:22 PM
>> To: dev at dpdk.org
>> Cc: xavier.huwei at huawei.com
>> Subject: [dpdk-dev] [PATCH] app/testpmd: fix passing negative parameter to
>> strerror
>>
>> Currently, there are coverity defect warnings as blow:
>> Coverity issue:
>> In nic_stats_clear function:
>> CID 290021 (#1 of 1): Argument cannot be negative (NEGATIVE_RETURNS)
>> 5. negative_returns: ret is passed to a parameter that cannot be
>> negative.
>>
>> CID 289974 (#1 of 1): Argument cannot be negative (NEGATIVE_RETURNS)
>> 6. negative_returns: ret is passed to a parameter that cannot be
>> negative.
>>
>> In nic_xstats_clear function:
>> CID 289985 (#1 of 1): Argument cannot be negative (NEGATIVE_RETURNS)
>> 5. negative_returns: ret is passed to a parameter that cannot be
>> negative.
>>
>> CID 289850 (#1 of 1): Argument cannot be negative (NEGATIVE_RETURNS)
>> 6. negative_returns: ret is passed to a parameter that cannot be
>> negative.
>>
>> This patch fixes them by passing '-ret' to the function strerror() when ret
>> is negative.
>>
>> Fixes: af75078fece3 ("first public release")
>
> It was the commit da328f7f115a ("ethdev: change xstats reset function to return int") introduced this defect in nic_xstats_clear() function.
> Not the "first public release" commit. :)
>
> The patch looks good to me.
>
+1
> Thanks,
> Phil
>
>> Fixes: 9eb974221f44 ("app/testpmd: fix statistics after reset")
>> Cc: stable at dpdk.org
>>
>> Signed-off-by: Wei Hu (Xavier) <xavier.huwei at huawei.com>
>> ---
>> app/test-pmd/config.c | 8 ++++----
>> 1 file changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
>> index 5381207..356d0d2 100644
>> --- a/app/test-pmd/config.c
>> +++ b/app/test-pmd/config.c
>> @@ -244,14 +244,14 @@ nic_stats_clear(portid_t port_id)
>> ret = rte_eth_stats_reset(port_id);
>> if (ret != 0) {
>> printf("%s: Error: failed to reset stats (port %u): %s",
>> - __func__, port_id, strerror(ret));
>> + __func__, port_id, strerror(-ret));
>> return;
>> }
>>
>> ret = rte_eth_stats_get(port_id, &ports[port_id].stats);
>> if (ret != 0) {
>> printf("%s: Error: failed to get stats (port %u): %s",
>> - __func__, port_id, strerror(ret));
>> + __func__, port_id, strerror(-ret));
>> return;
>> }
>> printf("\n NIC statistics for port %d cleared\n", port_id);
>> @@ -333,14 +333,14 @@ nic_xstats_clear(portid_t port_id)
>> ret = rte_eth_xstats_reset(port_id);
>> if (ret != 0) {
>> printf("%s: Error: failed to reset xstats (port %u): %s",
>> - __func__, port_id, strerror(ret));
>> + __func__, port_id, strerror(-ret));
>> return;
>> }
>>
>> ret = rte_eth_stats_get(port_id, &ports[port_id].stats);
>> if (ret != 0) {
>> printf("%s: Error: failed to get stats (port %u): %s",
>> - __func__, port_id, strerror(ret));
>> + __func__, port_id, strerror(-ret));
>> return;
>> }
>> }
>> --
>> 2.7.4
>
More information about the dev
mailing list