From 19c21b24ae3cbd55c14c2a1c1a1dedbc705a591f 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 a368b54c2..5be93faa8 100644 --- a/dix/dix_priv.h +++ b/dix/dix_priv.h @@ -39,6 +39,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;