From mboxrd@z Thu Jan 1 00:00:00 1970 From: Olivier MATZ Subject: Re: [PATCH v2 09/13] mbuf: introduce new checksum API Date: Tue, 18 Nov 2014 10:10:47 +0100 Message-ID: <546B0D17.7050503@6wind.com> References: <1415635166-1364-1-git-send-email-olivier.matz@6wind.com> <1415984609-2484-1-git-send-email-olivier.matz@6wind.com> <1415984609-2484-10-git-send-email-olivier.matz@6wind.com> <2601191342CEEE43887BDE71AB977258213AE563@IRSMSX105.ger.corp.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: "jigsaw-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" To: "Ananyev, Konstantin" , "dev-VfR2kkLFssw@public.gmane.org" Return-path: In-Reply-To: <2601191342CEEE43887BDE71AB977258213AE563-kPTMFJFq+rEu0RiL9chJVbfspsVTdybXVpNB7YpNyf8@public.gmane.org> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces-VfR2kkLFssw@public.gmane.org Sender: "dev" Hi Konstantin, On 11/17/2014 07:15 PM, Ananyev, Konstantin wrote: > Just 2 nits from me: > > 1) >> +static inline uint16_t >> +rte_raw_cksum(const char *buf, size_t len) >> +{ > ... >> + while (len >= 8) { >> + sum += u16[0]; sum += u16[1]; sum += u16[2]; sum += u16[3]; > > Can you put each expression into a new line? > sum += u16[0]; > sum += u16[1]; > ... > > To make it easier to read. > Or can it be rewritten just like: > sum = (uint32_t)u16[0] + u16[1] + u16[2] + u16[3]; > here? > > 2) >> + while (len >= 8) { >> + sum += u16[0]; sum += u16[1]; sum += u16[2]; sum += u16[3]; >> + len -= 8; >> + u16 += 4; >> + } >> + while (len >= 2) { >> + sum += *u16; >> + len -= 2; >> + u16 += 1; >> + } > > In the code above, probably use sizeof(u16[0]) wherever appropriate. > To make things a bit more clearer and consistent. > ... > while (len >= 4 * sizeof(u16[0])) > len -= 4 * sizeof(u16[0]); > u16 += 4; > ... > Same for second loop OK, I push that in the todo list for the v3. Thanks, Olivier