From 8e84c354313c0f769939cce0dd7b0f276c40cb56 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Mon, 14 Jul 2025 23:46:52 +0200 Subject: [PATCH] dix: macro for checking X protocol types The X protocol types from xorgproto all have corresponding sz_ defines with their actual network payload size (this can be checked via SIZEOF() macro). In theory, this should always be the same as sizeof(), but just to be sure, adding a macro for a static assert on that. Signed-off-by: Enrico Weigelt, metux IT consult --- dix/dix_priv.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/dix/dix_priv.h b/dix/dix_priv.h index c3dc45fac1..550091937a 100644 --- a/dix/dix_priv.h +++ b/dix/dix_priv.h @@ -38,6 +38,13 @@ } \ } while (0) +/* static assert for protocol structure sizes */ +#ifndef __size_assert +#define __size_assert(what, howmuch) \ + typedef char what##_size_wrong_[( !!(sizeof(what) == howmuch) )*2-1 ] +#endif +#define XTYPE_SIZE_ASSERT(typename) __size_assert(typename,SIZEOF(typename)) + /* server setting: maximum size for big requests */ #define MAX_BIG_REQUEST_SIZE 4194303 extern long maxBigRequestSize;