[dpdk-dev] [PATCH v8 02/11] eal/linux: add rte_epoll_wait/ctl support

Liang, Cunming cunming.liang at intel.com
Fri May 22 04:08:27 CEST 2015



On 5/22/2015 2:17 AM, Stephen Hemminger wrote:
> On Thu, 21 May 2015 16:55:54 +0800
> Cunming Liang <cunming.liang at intel.com> wrote:
>
>> +static int
>> +eal_epoll_process_event(struct epoll_event *evs, int n,
>> +			struct rte_epoll_event *events)
>> +{
>> +	int i;
>> +	int count = 0;
>> +	struct rte_epoll_event *rev;
>> +	for (i = 0; i < n; i++) {
>> +		rev = (struct rte_epoll_event *)evs[i].data.ptr;
>> +		if (!rev || !rte_atomic32_cmpset(&rev->status, RTE_EPOLL_VALID,
>> +						 RTE_EPOLL_EXEC))
>> +			continue;
>> +
>> +		events[count].status        = RTE_EPOLL_VALID;
>> +		events[count].fd            = rev->fd;
>> +		events[count].epfd          = rev->epfd;
>> +		events[count].epdata.event  = rev->epdata.event;
>> +		events[count].epdata.data   = rev->epdata.data;
> This code has several style issues:
>   1. Always put blank line after declarations
>
>   2. Use unsigned where ever it makes sense as a matter of habit.
>        unsigned int i, count = 0;
>
>   3. Don't add casts where not necessary, it reduces compiler type checking
>      and is a bad habit. In this case evs[i].data.ptr is void *
>      and therefore no cast is needed.
Fully agree, thanks for the comment.


More information about the dev mailing list