From mboxrd@z Thu Jan 1 00:00:00 1970 From: Lukasz Majewski Date: Wed, 07 May 2014 14:25:27 +0200 Subject: [U-Boot] [PATCH v2] lib:crc32: Allow setting of the initial crc32 value In-Reply-To: <20140507104240.3D336380180@gemini.denx.de> References: <1399295277-28334-1-git-send-email-l.majewski@samsung.com> <1399443021-11748-1-git-send-email-l.majewski@samsung.com> <20140507104240.3D336380180@gemini.denx.de> Message-ID: <20140507142527.2132465f@amdc2363> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hi Wolfgang, > Dear Lukasz Majewski, > > In message <1399443021-11748-1-git-send-email-l.majewski@samsung.com> > you wrote: > > The current approach set the initial value of crc32 calculation to > > zero, which is correct for calculating checksum of the whole chunk > > of data. > ... > > + if (*output) > > + memcpy(&crc, output, sizeof(crc)); > > + > > + crc = crc32_wd(crc, input, ilen, chunk_sz); > > crc = htonl(crc); > > memcpy(output, &crc, sizeof(crc)); > > You can actually remove the "if (*output)" because output has always > to be a non-null pointer, as we're going to store the result there. I think, that the above statement would be correct if I had checked the if (output). The problem here is that *output refers to uint8 and only first/last byte is checked. This is obviously wrong. You are right that this check is not needed. > > Which means that you cannot use this to implicitly initialize crc =0, > whichin turn means you MUST add porper initialization to all callers > of that function. Ok. > > Best regards, > > Wolfgang Denk > -- Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group