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.
This commit is contained in:
John "Elwin" Edwards 2015-04-21 10:11:02 -04:00
parent 034d8d6484
commit 02cec53f85
3 changed files with 16 additions and 22 deletions

View file

@ -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;
}
}

View file

@ -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 */

View file

@ -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;