Date: Mon, 7 Dec 2020 12:11:46 +0000 From: Jessica Clarke <jrtc27@freebsd.org> To: Toomas Soome <tsoome@FreeBSD.org> Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r368410 - head/stand/libsa/zfs Message-ID: <AF746076-9488-487D-84F3-F3D0D86B3745@freebsd.org> In-Reply-To: <202012071125.0B7BPIt4017680@repo.freebsd.org> References: <202012071125.0B7BPIt4017680@repo.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On 7 Dec 2020, at 11:25, Toomas Soome <tsoome@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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AF746076-9488-487D-84F3-F3D0D86B3745>