Re: [PATCH 1/2] xfs: add CRC infrastructure

Andi Kleen
2012-11-07T16:19:32Z

Dave Chinner <david@fromorbit.com> writes:
> + */
> +static inline __uint32_t
> +xfs_start_cksum(char *buffer, size_t length, unsigned long cksum_offset)
> +{
> + __uint32_t zero = 0;
> + __uint32_t crc;
> +
> + /* Calculate CRC up to the checksum. */
> + crc = crc32c(XFS_CRC_SEED, buffer, cksum_offset);
> +
> + /* Skip checksum field */
> + crc = crc32c(crc, &zero, sizeof(__u32));
> +
> + /* Calculate the rest of the CRC. */
> + return crc32c(crc, &buffer[cksum_offset + sizeof(__be32)],
> + length - (cksum_offset + sizeof(__be32)));

Don't you need to remap a zero result to some other value, otherwise a
real zero checksum will never be checked?

-Andi

--
ak@linux.intel.com -- Speaking for myself only