changeset 134:cfa9d1609b78

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.
author John "Elwin" Edwards
date Tue, 21 Apr 2015 10:11:02 -0400
parents e6179860cb76
children ce0cf824c192
files xrogue/daemon.c xrogue/rogue.h xrogue/state.c
diffstat 3 files changed, 16 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/xrogue/daemon.c	Tue Apr 21 08:55:20 2015 -0400
+++ b/xrogue/daemon.c	Tue Apr 21 10:11:02 2015 -0400
@@ -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 @@
         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 @@
          * 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 @@
          * 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 @@
         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 @@
                 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 @@
               --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;
             }
         }
--- a/xrogue/rogue.h	Tue Apr 21 08:55:20 2015 -0400
+++ b/xrogue/rogue.h	Tue Apr 21 10:11:02 2015 -0400
@@ -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 */
--- a/xrogue/state.c	Tue Apr 21 08:55:20 2015 -0400
+++ b/xrogue/state.c	Tue Apr 21 10:11:02 2015 -0400
@@ -959,16 +959,6 @@
     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;