Subject: Re: [PATCH 1/3] csum-file: add hashwrite_be64()

From: Taylor Blau <[email-masked]>
Date: Thu, 12 Nov 2020 09:51:12 -0500

On Thu, Nov 12, 2020 at 01:20:19PM +0100, René Scharfe wrote:
> Add a helper function for hashing and writing 64-bit integers in network
> byte order.  It returns the number of written bytes.  This simplifies
> callers that keep track of the file offset, even though this number is a
> constant.
>
> Suggested-by: Derrick Stolee <[email-masked]>
> Original-patch-by: Taylor Blau <[email-masked]>
> Signed-off-by: René Scharfe <[email-masked]>
> ---
>  csum-file.h | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/csum-file.h b/csum-file.h
> index f9cbd317fb..e54d53d1d0 100644
> --- a/csum-file.h
> +++ b/csum-file.h
> @@ -62,4 +62,11 @@ static inline void hashwrite_be32(struct hashfile *f, uint32_t data)
>  	hashwrite(f, &data, sizeof(data));
>  }
>
> +static inline size_t hashwrite_be64(struct hashfile *f, uint64_t data)
> +{
> +	data = htonll(data);

Great. This is new from my patch (which wrote the high- and low four
bytes with two separate hashwrite_be32()'s), but I think it's a clear
improvement.

In addition to being more readable, we can use the bswap instruction
once instead of twice if it exists.

Please feel free to add my:

  Signed-off-by: Taylor Blau <[email-masked]>

Thanks,
Taylor