xfs
[Top] [All Lists]

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

To: Dave Chinner <david@xxxxxxxxxxxxx>
Subject: Re: [PATCH 1/2] xfs: add CRC infrastructure
From: Andi Kleen <andi@xxxxxxxxxxxxxx>
Date: Wed, 07 Nov 2012 08:21:27 -0800
Cc: xfs@xxxxxxxxxxx
In-reply-to: <1352295452-4726-2-git-send-email-david@xxxxxxxxxxxxx> (Dave Chinner's message of "Thu, 8 Nov 2012 00:37:31 +1100")
References: <1352295452-4726-1-git-send-email-david@xxxxxxxxxxxxx> <1352295452-4726-2-git-send-email-david@xxxxxxxxxxxxx>
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux)
Dave Chinner <david@xxxxxxxxxxxxx> 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@xxxxxxxxxxxxxxx -- Speaking for myself only

<Prev in Thread] Current Thread [Next in Thread>