From 2968701c3a461b94a5fa74619f4e30c4b9de2871 Mon Sep 17 00:00:00 2001 From: Michael Graff Date: Wed, 10 May 2000 17:45:45 +0000 Subject: [PATCH] require that magic numbers be the first item in the structure. --- lib/isc/include/isc/magic.h | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/isc/include/isc/magic.h b/lib/isc/include/isc/magic.h index ea1c5f8ed6..ac42a66b31 100644 --- a/lib/isc/include/isc/magic.h +++ b/lib/isc/include/isc/magic.h @@ -18,10 +18,18 @@ #ifndef ISC_MAGIC_H #define ISC_MAGIC_H 1 -#define ISC_MAGIC_VALID(a,b) (((a) != NULL) && ((a)->magic == (b))) +typedef struct { + unsigned int magic; +} isc__magic_t; -#define ISC_MAGIC(a, b, c, d) ((unsigned int)(a) << 24 \ - | (unsigned int)(b) << 16 \ - | (unsigned int)(c) << 8 | (d)) + +/* + * To use this macro the magic number MUST be the first thing in the + * structure, and MUST be of type "unsigned int" + */ +#define ISC_MAGIC_VALID(a,b) (((a) != NULL) \ + && (((isc__magic_t *)(a))->magic == (b))) + +#define ISC_MAGIC(a, b, c, d) ((a) << 24 | (b) << 16 | (c) << 8 | (d)) #endif /* ISC_MAGIC_H */