From 58e661e1cc9c46d32ff3b7c800df3631022c4d6c Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Mon, 10 Mar 2025 10:05:53 +0100 Subject: [PATCH] os: auth: improve readability and robustness of auth proto list The code is easier to understand, but also more robust (eg. against struct layout changes) if structs are initialized with explicit field names instead of as lists. Signed-off-by: Enrico Weigelt, metux IT consult --- os/auth.c | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/os/auth.c b/os/auth.c index de2aae917..b1011a7ec 100644 --- a/os/auth.c +++ b/os/auth.c @@ -66,21 +66,28 @@ struct protocol { }; static struct protocol protocols[] = { - {(unsigned short) 18, "MIT-MAGIC-COOKIE-1", - MitAddCookie, MitCheckCookie, MitResetCookie, - MitFromID, MitRemoveCookie, + { + .name_length = 18, + .name = "MIT-MAGIC-COOKIE-1", + .Add = MitAddCookie, + .Check = MitCheckCookie, + .Reset = MitResetCookie, + .FromID = MitFromID, + .Remove = MitRemoveCookie, #ifdef XCSECURITY - MitGenerateCookie + .Generate = MitGenerateCookie #endif - }, + }, #ifdef HASXDMAUTH - {(unsigned short) 19, "XDM-AUTHORIZATION-1", - XdmAddCookie, XdmCheckCookie, XdmResetCookie, - XdmFromID, XdmRemoveCookie, -#ifdef XCSECURITY - NULL -#endif - }, + { + .name_length = 19, + .name = "XDM-AUTHORIZATION-1", + .Add = XdmAddCookie, + .Check = XdmCheckCookie, + .Reset = XdmResetCookie, + .FromID = XdmFromID, + .Remove = XdmRemoveCookie, + }, #endif };