[dpdk-dev] Unsafe array accesses in rte_sched.c
Simon Kågström
simon.kagstrom at netinsight.net
Fri Oct 16 15:50:55 CEST 2015
On 2015-10-16 15:39, Dumitrescu, Cristian wrote:
>> port->qsize_add[12] = port->qsize_add[11] + port->qsize[2];
>> port->qsize_add[13] = port->qsize_add[12] + port->qsize[3];
>> port->qsize_add[14] = port->qsize_add[13] + port->qsize[3];
>> port->qsize_add[15] = port->qsize_add[14] + port->qsize[3];
>>
>> port->qsize_sum = port->qsize_add[15] + port->qsize[3];
>> }
>>
>> but port->qsize is actually defined as
>>
>> uint16_t qsize[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
>>
>
> Not sure what you see "unsafe" here: qsize is an array of 4 elements, while qsize_add is a different array of 16 elements? Please explain.
Sorry, I should have been more explicit: What I mean that the code
should loop over RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE instead of
hard-coding the numbers.
It certainly works with the current RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE,
but it would be safer (and in my opinion more clear) if it would not
assume RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE == 4.
// Simon
More information about the dev
mailing list