svn commit: r368410 - head/stand/libsa/zfs

Jessica Clarke jrtc27 at freebsd.org
Mon Dec 7 12:11:50 UTC 2020


On 7 Dec 2020, at 11:25, Toomas Soome <tsoome at FreeBSD.org> wrote:
> @@ -183,28 +215,29 @@ xdr_u_int(xdr_t *xdr, unsigned *ip)
> static bool
> xdr_int64(xdr_t *xdr, int64_t *lp)
> {
> -	int hi;
> -	unsigned lo;
> 	bool rv = false;
> 
> -	if (xdr->xdr_idx + sizeof (int64_t) > xdr->xdr_buf + xdr->xdr_buf_size)
> +	if (xdr->xdr_idx + sizeof(int64_t) > xdr->xdr_buf + xdr->xdr_buf_size)
> 		return (rv);
> 
> 	switch (xdr->xdr_op) {
> 	case XDR_OP_ENCODE:
> 		/* Encode value *lp, store to buf */
> -		hi = *lp >> 32;
> -		lo = *lp & UINT32_MAX;
> -		xdr->xdr_idx += xdr->xdr_putint(xdr, hi);
> -		xdr->xdr_idx += xdr->xdr_putint(xdr, lo);
> +		if (xdr->xdr_putint == _putint)
> +			*(int64_t *)xdr->xdr_idx = htobe64(*lp);
> +		else
> +			*(int64_t *)xdr->xdr_idx = *lp;

I don't know the details here, but inspecting the callback function and
comparing it against a known one to decide what to do is generally not
good practice. Can this be pushed down into the function in question,
up into the caller or additional information passed to be explicit
about this behaviour rather than brittle magic behaviour?

Jess




Jess



More information about the svn-src-head mailing list