[dpdk-dev] [PATCH v6] af_packet: Fix some klocwork errors

Pawel Wodkowski pawelx.wodkowski at intel.com
Tue Mar 10 09:59:40 CET 2015


On 2015-03-10 09:49, Ouyang, Changchun wrote:
>
>
>> -----Original Message-----
>> From: Wodkowski, PawelX
>> Sent: Tuesday, March 10, 2015 4:37 PM
>> To: Ouyang, Changchun; dev at dpdk.org
>> Cc: linville at tuxdriver.com; nhorman at tuxdriver.com
>> Subject: Re: [PATCH v6] af_packet: Fix some klocwork errors
>>
>>> -
>>> -	return 0;
>>> +exit:
>>> +	if (kvlist != NULL)
>>
>> No need for if(). This part was fine previous patch.
>>
>
> If kvlist is NULL, no reason to call rte_kvargs_free to free it.
> So, adding this test is better.

For programmer convenience and reduce code bloat/obfuscation the same 
test is in rte_kvargs_free() (and every other free-like function). If 
there is no particular reason for that (ex performance which is not in 
this path) checking pointer for NULL value should be avoided before 
freeing it.

>
>>> +		rte_kvargs_free(kvlist);
>>> +	return ret;
>>>    }
>>>
>>>    static struct rte_driver pmd_af_packet_drv = {
>>>
>>
>>
>> --
>> Pawel


-- 
Pawel


More information about the dev mailing list