aboutsummaryrefslogtreecommitdiff
path: root/type.c
diff options
context:
space:
mode:
authorFlavio Cruz <flaviocruz@gmail.com>2022-11-14 00:40:07 -0500
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2022-11-15 02:45:08 +0100
commitf51fc836c5b690f5448e76196dd40bdb55957a11 (patch)
treeee536320125658080ae96b1085278f83e042e7e2 /type.c
parent3902cb2fcae6e2028252b5d2016bf0e99ed74980 (diff)
downloadmig-f51fc836c5b690f5448e76196dd40bdb55957a11.tar.gz
mig-f51fc836c5b690f5448e76196dd40bdb55957a11.tar.bz2
mig-f51fc836c5b690f5448e76196dd40bdb55957a11.zip
Initialize basic types once and print errors for duplicate definitions
For kernel server or user subsystems we would initialize basic types twice, once in main() and again for the subsystem declaration. Instead, initialize basic types when the subsystem is declared and then throw errors when types are defined multiple times. Message-Id: <Y3HUt/YAKaqMMTi3@viriathus>
Diffstat (limited to 'type.c')
-rw-r--r--type.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/type.c b/type.c
index 66944d9..3846746 100644
--- a/type.c
+++ b/type.c
@@ -57,6 +57,7 @@ ipc_type_t *itWaitTimeType; /* used for dummy WaitTime args */
ipc_type_t *itMsgOptionType; /* used for dummy MsgOption args */
ipc_type_t *itShortType; /* used for the short type */
ipc_type_t *itIntType; /* used for the int type */
+static boolean_t types_initialized = FALSE;
static ipc_type_t *list = itNULL;
@@ -67,6 +68,13 @@ static ipc_type_t *list = itNULL;
ipc_type_t *
itLookUp(identifier_t name)
{
+ if (!types_initialized)
+ {
+ error("Basic types not initialized when looking up type %s. Did you "
+ "forget to define the subsystem?", name);
+ return NULL;
+ }
+
ipc_type_t *it, **last;
for (it = *(last = &list); it != itNULL; it = *(last = &it->itNext))
@@ -875,6 +883,14 @@ itMakeDeallocType(void)
void
init_type(void)
{
+ if (types_initialized)
+ {
+ error("Basic types were already initialized");
+ exit(EXIT_FAILURE);
+ }
+ /* Mark initialization here since itInsert below will require it. */
+ types_initialized = TRUE;
+
itByteType = itAlloc();
itByteType->itName = "unsigned char";
itByteType->itInName = MACH_MSG_TYPE_BYTE;