Module Name:    othersrc
Committed By:   dholland
Date:           Mon Mar  4 23:31:57 UTC 2013

Modified Files:
        othersrc/usr.bin/dholland-make2: make.c make.h targ.c

Log Message:
Use (far) fewer void pointers now that we're free of that list library.
Also drop meaningless always-zero integer return values that the list
library needed for its function pointers.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 othersrc/usr.bin/dholland-make2/make.c \
    othersrc/usr.bin/dholland-make2/targ.c
cvs rdiff -u -r1.6 -r1.7 othersrc/usr.bin/dholland-make2/make.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: othersrc/usr.bin/dholland-make2/make.c
diff -u othersrc/usr.bin/dholland-make2/make.c:1.5 othersrc/usr.bin/dholland-make2/make.c:1.6
--- othersrc/usr.bin/dholland-make2/make.c:1.5	Mon Mar  4 23:03:42 2013
+++ othersrc/usr.bin/dholland-make2/make.c	Mon Mar  4 23:31:57 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: make.c,v 1.5 2013/03/04 23:03:42 dholland Exp $	*/
+/*	$NetBSD: make.c,v 1.6 2013/03/04 23:31:57 dholland Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -111,7 +111,7 @@
 #include    "dir.h"
 #include    "job.h"
 
-MAKE_RCSID("$NetBSD: make.c,v 1.5 2013/03/04 23:03:42 dholland Exp $");
+MAKE_RCSID("$NetBSD: make.c,v 1.6 2013/03/04 23:31:57 dholland Exp $");
 
 static unsigned int checked = 1;/* Sequence # to detect recursion */
 static Lst     	toBeMade;	/* The current fringe of the graph. These
@@ -120,18 +120,17 @@ static Lst     	toBeMade;	/* The current
 				 * Make_Update and subtracted from by
 				 * MakeStartJobs */
 
-static int MakeAddChild2(void *, void *);
-static int MakeFindChild(void *, void *);
-static int MakeUnmark(void *, void *);
-static int MakeAddAllSrc(void *, void *);
-static int MakeTimeStamp(void *, void *);
-static int MakeHandleUse(void *, void *);
+static void MakeAddChild(GNode *, GList *);
+static void MakeFindChild(GNode *, GNode *);
+static void MakeUnmark(GNode *);
+static void MakeAddAllSrc(GNode *, GNode *);
+static void MakeHandleUse(GNode *, GNode *);
 static Boolean MakeStartJobs(void);
-static int MakePrintStatus(void *, void *);
-static int MakeCheckOrder(void *, void *);
+static int MakePrintStatus(GNode *, int *);
+static int MakeCheckOrder(GNode *);
 static int DoMakeCheckOrder(GList *);
-static int MakeBuildChild(void *, void *);
-static int MakeBuildParent(void *, void *);
+static int MakeBuildChild(GNode *, LstNode);
+static void MakeBuildParent(GNode *, LstNode);
 
 MAKE_ATTR_DEAD static void
 make_abort(GNode *gn, int line)
@@ -156,33 +155,21 @@ make_abort(GNode *gn, int line)
  *	cgn		the child we've just examined
  *
  * Results:
- *	Always returns 0.
+ *	None
  *
  * Side Effects:
  *	The cmgn of the parent node will be changed if the mtime
  *	field of the child is greater than it.
  *-----------------------------------------------------------------------
  */
-int
+void
 Make_TimeStamp(GNode *pgn, GNode *cgn)
 {
     if (pgn->cmgn == NULL || cgn->mtime > pgn->cmgn->mtime) {
 	pgn->cmgn = cgn;
     }
-    return (0);
 }
 
-/*
- * Input:
- *	pgn		the current parent
- *	cgn		the child we've just examined
- *
- */
-static int
-MakeTimeStamp(void *pgn, void *cgn)
-{
-    return Make_TimeStamp((GNode *)pgn, (GNode *)cgn);
-}
 
 /*-
  *-----------------------------------------------------------------------
@@ -342,7 +329,7 @@ Make_OODate(GNode *gn)
 	unsigned i;
 
 	for (i=0; i<glist_num(&gn->parents); i++) {
-	    MakeTimeStamp(glist_get(&gn->parents, i), gn);
+	    Make_TimeStamp(glist_get(&gn->parents, i), gn);
 	}
     }
 
@@ -354,51 +341,28 @@ Make_OODate(GNode *gn)
  * MakeAddChild  --
  *	Function used by Make_Run to add a child to the list l.
  *	It will only add the child if its make field is FALSE.
- * MakeAddChild2  --
- *      Same but lp is a GList, not a Lst.
  *
  * Input:
  *	gnp		the node to add
  *	lp		the list to which to add it
  *
  * Results:
- *	Always returns 0
+ *	None
  *
  * Side Effects:
  *	The given list is extended
  *-----------------------------------------------------------------------
  */
-#if 0
-static int
-MakeAddChild(void *gnp, void *lp)
-{
-    GNode          *gn = (GNode *)gnp;
-    Lst            l = (Lst) lp;
 
-    if ((gn->flags & REMAKE) == 0 && !(gn->type & (OP_USE|OP_USEBEFORE))) {
-	if (DEBUG(MAKE))
-	    fprintf(debug_file, "MakeAddChild: need to examine %s%s\n",
-		gn->name, gn->cohort_num);
-	(void)Lst_EnQueue(l, gn);
-    }
-    return (0);
-}
-#endif
-
-/* array variant */
-static int
-MakeAddChild2(void *gnp, void *lp)
+static void
+MakeAddChild(GNode *gn, GList *l)
 {
-    GNode          *gn = (GNode *)gnp;
-    GList          *l = lp;
-
     if ((gn->flags & REMAKE) == 0 && !(gn->type & (OP_USE|OP_USEBEFORE))) {
 	if (DEBUG(MAKE))
 	    fprintf(debug_file, "MakeAddChild: need to examine %s%s\n",
 		gn->name, gn->cohort_num);
 	glist_add(l, gn, NULL);
     }
-    return (0);
 }
 
 /*-
@@ -408,27 +372,23 @@ MakeAddChild2(void *gnp, void *lp)
  *	that was already made.
  *
  * Input:
- *	gnp		the node to find
+ *	gn		the node to find
+ *      pgn		parent of gn
  *
  * Results:
- *	Always returns 0
+ *	None
  *
  * Side Effects:
  *	The path and mtime of the node and the cmgn of the parent are
  *	updated; the unmade children count of the parent is decremented.
  *-----------------------------------------------------------------------
  */
-static int
-MakeFindChild(void *gnp, void *pgnp)
+static void
+MakeFindChild(GNode *gn, GNode *pgn)
 {
-    GNode          *gn = (GNode *)gnp;
-    GNode          *pgn = (GNode *)pgnp;
-
     (void)Dir_MTime(gn, 0);
     Make_TimeStamp(pgn, gn);
     pgn->unmade--;
-
-    return (0);
 }
 
 /*-
@@ -536,25 +496,23 @@ Make_HandleUse(GNode *cgn, GNode *pgn)
  *	pgnp		the current parent
  *
  * Results:
- *	returns 0.
+ *	None
  *
  * Side Effects:
  *	After expansion, .USE child nodes are removed from the parent
  *
  *-----------------------------------------------------------------------
  */
-static int
-MakeHandleUse(void *cgnp, void *pgnp)
+static void
+MakeHandleUse(GNode *cgn, GNode *pgn)
 {
-    GNode	*cgn = (GNode *)cgnp;
-    GNode	*pgn = (GNode *)pgnp;
     int		unmarked;
 
     unmarked = ((cgn->type & OP_MARK) == 0);
     cgn->type |= OP_MARK;
 
     if ((cgn->type & (OP_USE|OP_USEBEFORE)) == 0)
-	return (0);
+	return;
 
     if (unmarked)
 	Make_HandleUse(cgn, pgn);
@@ -570,7 +528,6 @@ MakeHandleUse(void *cgnp, void *pgnp)
 	glist_removeval(&pgn->children, cgn);
 	pgn->unmade--;
     }
-    return (0);
 }
 
 
@@ -746,9 +703,7 @@ Make_Update(GNode *cgn)
 
 	for (i=0; i<glist_num(&centurion->order_succ); i++) {
 	    succ = glist_get(&centurion->order_succ, i);
-	    if (MakeBuildParent(succ, Lst_First(toBeMade))) {
-		break;
-	    }
+	    MakeBuildParent(succ, Lst_First(toBeMade));
 	}
     }
 
@@ -888,19 +843,16 @@ Make_Update(GNode *cgn)
  *	modification times, the comparison is rather unfair...)..
  *
  * Results:
- *	Always returns 0
+ *	None
  *
  * Side Effects:
  *	The ALLSRC variable for the given node is extended.
  *-----------------------------------------------------------------------
  */
-static int
-MakeUnmark(void *cgnp, void *pgnp MAKE_ATTR_UNUSED)
+static void
+MakeUnmark(GNode *cgn)
 {
-    GNode	*cgn = (GNode *)cgnp;
-
     cgn->type &= ~OP_MARK;
-    return (0);
 }
 
 /*
@@ -910,14 +862,11 @@ MakeUnmark(void *cgnp, void *pgnp MAKE_A
  *			be added
  *
  */
-static int
-MakeAddAllSrc(void *cgnp, void *pgnp)
+static void
+MakeAddAllSrc(GNode *cgn, GNode *pgn)
 {
-    GNode	*cgn = (GNode *)cgnp;
-    GNode	*pgn = (GNode *)pgnp;
-
     if (cgn->type & OP_MARK)
-	return (0);
+	return;
     cgn->type |= OP_MARK;
 
     if ((cgn->type & (OP_EXEC|OP_USE|OP_USEBEFORE|OP_INVISIBLE)) == 0) {
@@ -965,7 +914,6 @@ MakeAddAllSrc(void *cgnp, void *pgnp)
 	if (p1)
 	    free(p1);
     }
-    return (0);
 }
 
 /*-
@@ -999,15 +947,11 @@ Make_DoAllVar(GNode *gn)
 	return;
 
     for (i=0; i<glist_num(&gn->children); i++) {
-	if (MakeUnmark(glist_get(&gn->children, i), gn)) {
-	    break;
-	}
+	MakeUnmark(glist_get(&gn->children, i));
     }
     /* XXX: does this need to be a separate loop? */
     for (i=0; i<glist_num(&gn->children); i++) {
-	if (MakeAddAllSrc(glist_get(&gn->children, i), gn)) {
-	    break;
-	}
+	MakeAddAllSrc(glist_get(&gn->children, i), gn);
     }
 
     if (!Var_Exists (OODATE, gn)) {
@@ -1044,10 +988,8 @@ Make_DoAllVar(GNode *gn)
  */
 
 static int
-MakeCheckOrder(void *v_bn, void *ignore MAKE_ATTR_UNUSED)
+MakeCheckOrder(GNode *bn)
 {
-    GNode *bn = v_bn;
-
     if (bn->made >= MADE || !(bn->flags & REMAKE))
 	return 0;
     if (DEBUG(MAKE))
@@ -1070,7 +1012,7 @@ DoMakeCheckOrder(GList *order_pred)
 	return 0;
     }
     for (i=0; i<n; i++) {
-	if (MakeCheckOrder(glist_get(order_pred, i), 0)) {
+	if (MakeCheckOrder(glist_get(order_pred, i))) {
 	    return 1;
 	}
     }
@@ -1078,10 +1020,8 @@ DoMakeCheckOrder(GList *order_pred)
 }
 
 static int
-MakeBuildChild(void *v_cn, void *toBeMade_next)
+MakeBuildChild(GNode *cn, LstNode toBeMade_next)
 {
-    GNode *cn = v_cn;
-
     if (DEBUG(MAKE))
 	fprintf(debug_file, "MakeBuildChild: inspect %s%s, made %d, type %x\n",
 	    cn->name, cn->cohort_num, cn->made, cn->type);
@@ -1123,20 +1063,16 @@ MakeBuildChild(void *v_cn, void *toBeMad
 }
 
 /* When a .ORDER LHS node completes we do this on each RHS */
-static int
-MakeBuildParent(void *v_pn, void *toBeMade_next)
+static void
+MakeBuildParent(GNode *pn, LstNode toBeMade_next)
 {
-    GNode *pn = v_pn;
-
     if (pn->made != DEFERRED)
-	return 0;
+	return;
 
     if (MakeBuildChild(pn, toBeMade_next) == 0) {
 	/* Mark so that when this node is built we reschedule its parents */
 	pn->flags |= DONE_ORDER;
     }
-
-    return 0;
 }
 
 static Boolean
@@ -1240,22 +1176,20 @@ MakeStartJobs(void)
  *			inferior.
  *
  * Results:
- *	Always returns 0.
+ *	1 to stop printing
  *
  * Side Effects:
  *	A message may be printed.
  *
  *-----------------------------------------------------------------------
  */
-static int
-MakePrintStatusOrder(void *ognp, void *gnp)
+static void
+MakePrintStatusOrder(GNode *ogn, GNode *gn)
 {
-    GNode *ogn = ognp;
-    GNode *gn = gnp;
-
-    if (!(ogn->flags & REMAKE) || ogn->made > REQUESTED)
+    if (!(ogn->flags & REMAKE) || ogn->made > REQUESTED) {
 	/* not waiting for this one */
-	return 0;
+	return;
+    }
 
     printf("    `%s%s' has .ORDER dependency against %s%s "
 		"(made %d, flags %x, type %x)\n",
@@ -1266,19 +1200,17 @@ MakePrintStatusOrder(void *ognp, void *g
 		    "(made %d, flags %x, type %x)\n",
 		gn->name, gn->cohort_num,
 		ogn->name, ogn->cohort_num, ogn->made, ogn->flags, ogn->type);
-    return 0;
 }
 
 static int
-MakePrintStatus(void *gnp, void *v_errors)
+MakePrintStatus(GNode *gn, int *errors)
 {
-    GNode   	*gn = (GNode *)gnp;
-    int 	*errors = v_errors;
     unsigned i;
 
-    if (gn->flags & DONECYCLE)
+    if (gn->flags & DONECYCLE) {
 	/* We've completely processed this node before, don't do it again. */
 	return 0;
+    }
 
     if (gn->unmade == 0) {
 	gn->flags |= DONECYCLE;
@@ -1352,6 +1284,14 @@ MakePrintStatus(void *gnp, void *v_error
     }
     return 0;
 }
+
+/* non-typesafe thunk for list library; remove when possible (XXX) */
+static int
+doMakePrintStatus(void *gnp, void *errors)
+{
+    return MakePrintStatus(gnp, errors);
+}
+
 
 
 /*-
@@ -1434,7 +1374,7 @@ Make_ExpandUse(Lst targs)
 	(void)Dir_MTime(gn, 0);
 	Var_Set(TARGET, gn->path ? gn->path : gn->name, gn, 0);
 	for (i=0; i<glist_num(&gn->children); i++) {
-	    MakeUnmark(glist_get(&gn->children, i), gn);
+	    MakeUnmark(glist_get(&gn->children, i));
 	}
 	/* XXX: does this need to be a separate loop? */
 	for (i=0; i<glist_num(&gn->children); i++) {
@@ -1455,7 +1395,7 @@ Make_ExpandUse(Lst targs)
 
 	if (gn->unmade != 0) {
 	    for (i=0; i<glist_num(&gn->children); i++) {
-		MakeAddChild2(glist_get(&gn->children, i), &examine);
+		MakeAddChild(glist_get(&gn->children, i), &examine);
 	    }
 	}
     }
@@ -1488,11 +1428,8 @@ link_parent(void *cnp, void *pnp)
 }
 
 static int
-add_wait_dep(void *v_cn, void *v_wn)
+add_wait_dep(GNode *cn, GNode *wn)
 {
-    GNode *cn = v_cn;
-    GNode *wn = v_wn;
-
     if (cn == wn)
 	return 1;
 
@@ -1669,7 +1606,7 @@ Make_Run(Lst targs)
     if (DEBUG(MAKE))
 	 fprintf(debug_file, "done: errors %d\n", errors);
     if (errors == 0) {
-	Lst_ForEach(targs, MakePrintStatus, &errors);
+	Lst_ForEach(targs, doMakePrintStatus, &errors);
 	if (DEBUG(MAKE)) {
 	    fprintf(debug_file, "done: errors %d\n", errors);
 	    if (errors)
Index: othersrc/usr.bin/dholland-make2/targ.c
diff -u othersrc/usr.bin/dholland-make2/targ.c:1.5 othersrc/usr.bin/dholland-make2/targ.c:1.6
--- othersrc/usr.bin/dholland-make2/targ.c:1.5	Mon Mar  4 23:03:42 2013
+++ othersrc/usr.bin/dholland-make2/targ.c	Mon Mar  4 23:31:57 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: targ.c,v 1.5 2013/03/04 23:03:42 dholland Exp $	*/
+/*	$NetBSD: targ.c,v 1.6 2013/03/04 23:31:57 dholland Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -127,7 +127,7 @@
 #include	  "hash.h"
 #include	  "dir.h"
 
-MAKE_RCSID("$NetBSD: targ.c,v 1.5 2013/03/04 23:03:42 dholland Exp $");
+MAKE_RCSID("$NetBSD: targ.c,v 1.6 2013/03/04 23:31:57 dholland Exp $");
 
 static Lst        allTargets;	/* the list of all targets found so far */
 #ifdef CLEANUP
@@ -138,11 +138,11 @@ static Hash_Table targets;	/* a hash tab
 #define HTSIZE	191		/* initial size of hash table */
 
 static int TargPrintOnlySrc(void *, void *);
-static int TargPrintName(void *, void *);
+static void TargPrintName(GNode *);
 #ifdef CLEANUP
 static void TargFreeGN(void *);
 #endif
-static int TargPropagateCohort(void *, void *);
+static void TargPropagateCohort(GNode *, GNode *);
 static int TargPropagateNode(void *, void *);
 
 /*-
@@ -510,14 +510,10 @@ Targ_SetMain(GNode *gn)
     mainTarg = gn;
 }
 
-static int
-TargPrintName(void *gnp, void *pflags MAKE_ATTR_UNUSED)
+static void
+TargPrintName(GNode *gn)
 {
-    GNode *gn = (GNode *)gnp;
-
     fprintf(debug_file, "%s%s ", gn->name, gn->cohort_num);
-
-    return 0;
 }
 
 
@@ -661,7 +657,7 @@ Targ_PrintNode(void *gnp, void *passp)
 
 		fprintf(debug_file, "# implicit parents: ");
 		for (i=0; i<glist_num(&gn->iParents); i++) {
-		    TargPrintName(glist_get(&gn->iParents, i), NULL);
+		    TargPrintName(glist_get(&gn->iParents, i));
 		}
 		fprintf(debug_file, "\n");
 	    }
@@ -674,7 +670,7 @@ Targ_PrintNode(void *gnp, void *passp)
 
 	    fprintf(debug_file, "# parents: ");
 	    for (i=0; i<glist_num(&gn->parents); i++) {
-		TargPrintName(glist_get(&gn->parents, i), NULL);
+		TargPrintName(glist_get(&gn->parents, i));
 	    }
 	    fprintf(debug_file, "\n");
 	}
@@ -683,7 +679,7 @@ Targ_PrintNode(void *gnp, void *passp)
 
 	    fprintf(debug_file, "# order_pred: ");
 	    for (i=0; i<glist_num(&gn->order_pred); i++) {
-		TargPrintName(glist_get(&gn->order_pred, i), NULL);
+		TargPrintName(glist_get(&gn->order_pred, i));
 	    }
 	    fprintf(debug_file, "\n");
 	}
@@ -692,7 +688,7 @@ Targ_PrintNode(void *gnp, void *passp)
 
 	    fprintf(debug_file, "# order_succ: ");
 	    for (i=0; i<glist_num(&gn->order_succ); i++) {
-		TargPrintName(glist_get(&gn->order_succ, i), NULL);
+		TargPrintName(glist_get(&gn->order_succ, i));
 	    }
 	    fprintf(debug_file, "\n");
 	}
@@ -711,7 +707,7 @@ Targ_PrintNode(void *gnp, void *passp)
 	    unsigned i;
 
 	    for (i=0; i<glist_num(&gn->children); i++) {
-		TargPrintName(glist_get(&gn->children, i), NULL);
+		TargPrintName(glist_get(&gn->children, i));
 	    }
 	}
 	fprintf(debug_file, "\n");
@@ -846,14 +842,10 @@ TargPropagateNode(void *gnp, void *junk 
  *	bits from gnp's type bitmask.  (XXX need a better explanation.)
  *-----------------------------------------------------------------------
  */
-static int
-TargPropagateCohort(void *cgnp, void *pgnp)
+static void
+TargPropagateCohort(GNode *cgn, GNode *pgn)
 {
-    GNode	  *cgn = (GNode *)cgnp;
-    GNode	  *pgn = (GNode *)pgnp;
-
     cgn->type |= pgn->type & ~OP_OPMASK;
-    return (0);
 }
 
 /*-

Index: othersrc/usr.bin/dholland-make2/make.h
diff -u othersrc/usr.bin/dholland-make2/make.h:1.6 othersrc/usr.bin/dholland-make2/make.h:1.7
--- othersrc/usr.bin/dholland-make2/make.h:1.6	Mon Mar  4 05:50:49 2013
+++ othersrc/usr.bin/dholland-make2/make.h	Mon Mar  4 23:31:57 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: make.h,v 1.6 2013/03/04 05:50:49 dholland Exp $	*/
+/*	$NetBSD: make.h,v 1.7 2013/03/04 23:31:57 dholland Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -266,7 +266,7 @@ extern int debug;
 
 #include "nonints.h"
 
-int Make_TimeStamp(GNode *, GNode *);
+void Make_TimeStamp(GNode *, GNode *);
 Boolean Make_OODate(GNode *);
 void Make_ExpandUse(Lst);
 time_t Make_Recheck(GNode *);

Reply via email to