From a95ae61658f25ea88d9d9b7a08c965cbb1733709 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Thu, 14 Aug 2025 18:58:29 +0200 Subject: [PATCH] dix: rpcbuf: add rpcbuf_write_INT16() Just a convenience wrapper for writing an INT16. Technically it's really the same as CARD16, but we still need a typecast in order to not getting a compiler warning on int signedness mismatch. Signed-off-by: Enrico Weigelt, metux IT consult --- dix/rpcbuf_priv.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/dix/rpcbuf_priv.h b/dix/rpcbuf_priv.h index 0914ddd317..2571ecbcda 100644 --- a/dix/rpcbuf_priv.h +++ b/dix/rpcbuf_priv.h @@ -169,6 +169,22 @@ Bool x_rpcbuf_write_CARD8(x_rpcbuf_t *rpcbuf, CARD8 value) Bool x_rpcbuf_write_CARD16(x_rpcbuf_t *rpcbuf, CARD16 value) _X_ATTRIBUTE_NONNULL_ARG(1); +/* + * write a INT16 and do byte-swapping (when needed). + * + * allocate a region for INT16, write it into the buffer and do byte-swap + * if buffer is configured to do so (`swapped` field is TRUE). + * + * doesn't do any padding. + * + * @param rpcbuf pointer to x_rpcbuf_t to operate on + * @param value the CARD16 value to write + * @return TRUE on success, FALSE on allocation failure + */ +static inline Bool x_rpcbuf_write_INT16(x_rpcbuf_t *rpcbuf, INT16 value) { + return x_rpcbuf_write_CARD16(rpcbuf, (CARD16)value); +} + /* * write a CARD32 and do byte-swapping (when needed). *