[dpdk-dev] [PATCH] all: refactor coding style

Shreyansh Jain shreyansh.jain at nxp.com
Thu Jul 20 09:13:40 CEST 2017


On Thursday 20 July 2017 11:23 AM, Tiwei Bie wrote:
> On Thu, Jul 20, 2017 at 10:34:39AM +0530, Shreyansh Jain wrote:
>> On Wednesday 19 July 2017 02:36 PM, Tiwei Bie wrote:
>>> Remove the unwanted spaces before `;' across DPDK source code
>>> by below one-liner with some minor manual refinements.
>>>
>>> find . -name '*.[ch]' | xargs sed -i 's/\([^;(]\) \+;/\1;/g'
>>>
>>> The fixes for cmdline library are skipped, because it has a
>>> different coding style. It deserves a separate cleanup if
>>> necessary. The fixes for drivers' base code are also skipped
>>> to keep the base code intact.
>>>
>>> Signed-off-by: Tiwei Bie <tiwei.bie at intel.com>
>>> ---
> [...]
>>>    		/* compute the number of steps to the right */
>>> diff --git a/lib/librte_sched/rte_bitmap.h b/lib/librte_sched/rte_bitmap.h
>>> index 010d752..e487b58 100644
>>> --- a/lib/librte_sched/rte_bitmap.h
>>> +++ b/lib/librte_sched/rte_bitmap.h
>>> @@ -500,7 +500,8 @@ __rte_bitmap_scan_read(struct rte_bitmap *bmp, uint32_t *pos, uint64_t *slab)
>>>    	uint64_t *slab2;
>>>    	slab2 = bmp->array2 + bmp->index2;
>>> -	for ( ; bmp->go2 ; bmp->index2 ++, slab2 ++, bmp->go2 = bmp->index2 & RTE_BITMAP_CL_SLAB_MASK) {
>>> +	for ( ; bmp->go2; bmp->index2++, slab2++,
>>> +			  bmp->go2 = bmp->index2 & RTE_BITMAP_CL_SLAB_MASK) {
>>
>>             ^^^^
>> Trivial: space before ';' in 'for' here should also be removed.
>>
> 
> Thank you for your feedbacks! :-)
> 
> Hmm.. Actually the space between `(' and `;' was kept intentionally
> when I wrote this 's/\([^;(]\) \+;/\1;/g' sed script. There are many
> other such cases. It's acceptable to me, and I thought we like it:

Ok.

> 
> diff --git i/app/test-eventdev/parser.h w/app/test-eventdev/parser.h
> index 75a5a3b..372b85f 100644
> --- i/app/test-eventdev/parser.h
> +++ w/app/test-eventdev/parser.h
> @@ -41,7 +41,7 @@
>   #define skip_white_spaces(pos)			\
>   ({						\
>   	__typeof__(pos) _p = (pos);		\
> -	for ( ; isspace(*_p); _p++)		\
> +	for (; isspace(*_p); _p++)		\
>   		;				\
>   	_p;					\

[...]

That is a long list of change :).
IMO, we should remove the space (in which case I agree with your change) 
- but, this is a more of a acceptable-coding-standards issue and I am 
not sure what the agreed standard for DPDK is in this case. Maybe Thomas 
can comment.

-
Shreyansh


More information about the dev mailing list