summaryrefslogtreecommitdiffstats
path: root/sys/kern/init_main.c
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>1998-10-15 17:09:19 +0000
committerpeter <peter@FreeBSD.org>1998-10-15 17:09:19 +0000
commit184dca28fb97c6067e7c11de26e93409157f7d83 (patch)
tree86c6877366f68c849779a3d347b63cabe7a8e18c /sys/kern/init_main.c
parentd1bde99276789c2ac3dfe59175fb418cefd1fe2d (diff)
downloadFreeBSD-src-184dca28fb97c6067e7c11de26e93409157f7d83.zip
FreeBSD-src-184dca28fb97c6067e7c11de26e93409157f7d83.tar.gz
Fix sysinit_add().
- Don't include multiple copies of the previous sysinit in the new one. - Leave space for and explicitly null terminate the new list.
Diffstat (limited to 'sys/kern/init_main.c')
-rw-r--r--sys/kern/init_main.c30
1 files changed, 17 insertions, 13 deletions
diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c
index d439a19..fffe109 100644
--- a/sys/kern/init_main.c
+++ b/sys/kern/init_main.c
@@ -39,7 +39,7 @@
* SUCH DAMAGE.
*
* @(#)init_main.c 8.9 (Berkeley) 1/21/94
- * $Id: init_main.c,v 1.97 1998/10/06 11:55:40 dfr Exp $
+ * $Id: init_main.c,v 1.98 1998/10/09 23:42:47 peter Exp $
*/
#include "opt_devfs.h"
@@ -143,26 +143,30 @@ sysinit_add(set)
struct sysinit **xipp;
int count = 0;
- for (sipp = sysinit; *sipp; sipp++)
- count++;
- for (sipp = set; *sipp; sipp++)
- count++;
if (newsysinit)
- for (sipp = set; *sipp; sipp++)
+ for (sipp = newsysinit; *sipp; sipp++)
count++;
+ else
+ for (sipp = sysinit; *sipp; sipp++)
+ count++;
+ for (sipp = set; *sipp; sipp++)
+ count++;
+ count++; /* Trailing NULL */
newset = malloc(count * sizeof(*sipp), M_TEMP, M_NOWAIT);
if (newset == NULL)
panic("cannot malloc for sysinit");
xipp = newset;
- for (sipp = sysinit; *sipp; sipp++)
- *xipp++ = *sipp;
- for (sipp = set; *sipp; sipp++)
- *xipp++ = *sipp;
- if (newsysinit) {
+ if (newsysinit)
for (sipp = newsysinit; *sipp; sipp++)
*xipp++ = *sipp;
- free(newset, M_TEMP);
- }
+ else
+ for (sipp = sysinit; *sipp; sipp++)
+ *xipp++ = *sipp;
+ for (sipp = set; *sipp; sipp++)
+ *xipp++ = *sipp;
+ *xipp = NULL;
+ if (newsysinit)
+ free(newsysinit, M_TEMP);
newsysinit = newset;
}
OpenPOWER on IntegriCloud