From 02cec53f85e0b3decbd269355092406fb0ba4f1e Mon Sep 17 00:00:00 2001 From: "John \"Elwin\" Edwards" Date: Tue, 21 Apr 2015 10:11:02 -0400 Subject: [PATCH] xrogue: fix definition of struct delayed_action. Arrays of struct delayed_action were declared before the definition. Also, daemon.c and state.c defined it differently. The state.c definition, in which d_arg is a union, is now used everywhere. This is the least bad option, but fuses and daemons are still a disheartening morass that undoubtedly shelters more bugs. --- xrogue/daemon.c | 18 ++++++------------ xrogue/rogue.h | 10 ++++++++++ xrogue/state.c | 10 ---------- 3 files changed, 16 insertions(+), 22 deletions(-) diff --git a/xrogue/daemon.c b/xrogue/daemon.c index 7418982..823c7f7 100644 --- a/xrogue/daemon.c +++ b/xrogue/daemon.c @@ -24,12 +24,6 @@ #define _X_ { EMPTY } -struct delayed_action { - int d_type; - int (*d_func)(); - VOID *d_arg; - int d_time; -} ; struct delayed_action d_list[MAXDAEMONS] = { _X_, _X_, _X_, _X_, _X_, _X_, _X_, _X_, _X_, _X_ }; @@ -107,7 +101,7 @@ reg int type, (*dfunc)(); if (dev != NULL) { dev->d_type = type; dev->d_func = dfunc; - dev->d_arg = arg; + dev->d_arg.vp = arg; dev->d_time = DAEMON; demoncnt += 1; /* update count */ } @@ -133,7 +127,7 @@ reg int (*dfunc)(); * Take it out of the list */ dev->d_type = EMPTY; - dev->d_arg = NULL; + dev->d_arg.vp = NULL; dev->d_func = NULL; dev->d_time = 0; @@ -162,7 +156,7 @@ reg int flag; * Executing each one, giving it the proper arguments */ if ((dev->d_type == flag) && (dev->d_time == DAEMON) && (dev->d_func != NULL)) - (*dev->d_func)(dev->d_arg); + (*dev->d_func)(dev->d_arg.vp); } } @@ -181,7 +175,7 @@ reg int (*dfunc)(), time, type; if (wire != NULL) { wire->d_type = type; wire->d_func = dfunc; - wire->d_arg = arg; + wire->d_arg.vp = arg; wire->d_time = time; fusecnt += 1; /* update count */ } @@ -216,7 +210,7 @@ reg int (*dfunc)(); return; wire->d_type = EMPTY; wire->d_func = NULL; - wire->d_arg = NULL; + wire->d_arg.vp = NULL; wire->d_time = 0; fusecnt -= 1; } @@ -245,7 +239,7 @@ reg int flag; --wire->d_time == 0) { wire->d_type = EMPTY; if (wire->d_func != NULL) - (*wire->d_func)(wire->d_arg); + (*wire->d_func)(wire->d_arg.vp); fusecnt -= 1; } } diff --git a/xrogue/rogue.h b/xrogue/rogue.h index d6235c6..eabfa61 100644 --- a/xrogue/rogue.h +++ b/xrogue/rogue.h @@ -927,6 +927,16 @@ #define MAXDAEMONS 10 #define MAXFUSES 20 +struct delayed_action { + int d_type; + int (*d_func)(); + union { + VOID *vp; + int i; + } d_arg; + int d_time; +}; + extern struct delayed_action d_list[MAXDAEMONS]; extern struct delayed_action f_list[MAXFUSES]; extern int demoncnt; /* number of active daemons */ diff --git a/xrogue/state.c b/xrogue/state.c index d69595d..1ce7428 100644 --- a/xrogue/state.c +++ b/xrogue/state.c @@ -959,16 +959,6 @@ rs_read_coord(int inf, coord *c) return(READSTAT); } -struct delayed_action { - int d_type; - int (*d_func)(); - union { - VOID *vp; - int i; - } d_arg; - int d_time; -}; - rs_write_daemons(FILE *savef, struct delayed_action *d_list,int count) { int i = 0;