> On Mar 3, 2021, at 2:13 AM, Christoph Hellwig <hch@xxxxxxxxxxxxx> wrote: > > On Mon, Mar 01, 2021 at 10:16:43AM -0500, Chuck Lever wrote: >> + *p++ = resp->p_no_trunc ? xdr_one : xdr_zero; >> + *p++ = resp->p_chown_restricted ? xdr_one : xdr_zero; >> + *p++ = resp->p_case_insensitive ? xdr_one : xdr_zero; >> + *p = resp->p_case_preserving ? xdr_one : xdr_zero; > > Wouldn't a little xdr_encode_bool helper for this common pattern be > nice? Sure. In include/linux/sunrpc/xdr.h, I've now added: /** * xdr_encode_bool - Encode a boolean item * @p: address in a buffer into which to encode * @n: boolean value to encode * * Return value: * Address of item following the encoded boolean */ static inline __be32 *xdr_encode_bool(__be32 *p, u32 n) { *p = n ? xdr_one : xdr_zero; return p++; } and xdr_stream_encode_bool() has been changed to use this helper. In fs/nfsd/nfs3xdr.c, the PATHCONF result encoder now uses xdr_encode_bool() to encode the four boolean fields in struct PATHCONF3resok. -- Chuck Lever