From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ernst.netinsight.se (ernst.netinsight.se [194.16.221.21]) by dpdk.org (Postfix) with SMTP id CB7DE8E5B for ; Fri, 16 Oct 2015 15:50:59 +0200 (CEST) Received: from [10.100.1.152] (unverified [10.100.1.152]) by ernst.netinsight.se (EMWAC SMTPRS 0.83) with SMTP id ; Fri, 16 Oct 2015 15:50:55 +0200 To: "Dumitrescu, Cristian" , "dev@dpdk.org" References: <5620BA12.9060702@netinsight.net> <3EB4FA525960D640B5BDFFD6A3D89126478F0C50@IRSMSX108.ger.corp.intel.com> From: =?UTF-8?Q?Simon_K=c3=a5gstr=c3=b6m?= Message-ID: <562100BF.9010107@netinsight.net> Date: Fri, 16 Oct 2015 15:50:55 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <3EB4FA525960D640B5BDFFD6A3D89126478F0C50@IRSMSX108.ger.corp.intel.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] Unsafe array accesses in rte_sched.c X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Oct 2015 13:51:00 -0000 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