diff --git a/src/windows.c b/src/windows.c index c87e4ca43..3a9471224 100644 --- a/src/windows.c +++ b/src/windows.c @@ -64,7 +64,8 @@ STATIC_DCL void FDECL(dump_clear_nhwindow, (winid)); STATIC_DCL void FDECL(dump_display_nhwindow, (winid, BOOLEAN_P)); STATIC_DCL void FDECL(dump_destroy_nhwindow, (winid)); STATIC_DCL void FDECL(dump_start_menu, (winid)); -STATIC_DCL void FDECL(dump_add_menu, (winid, int, const ANY_P *, CHAR_P, CHAR_P, int, const char *, BOOLEAN_P)); +STATIC_DCL void FDECL(dump_add_menu, (winid, int, const ANY_P *, CHAR_P, + CHAR_P, int, const char *, BOOLEAN_P)); STATIC_DCL void FDECL(dump_end_menu, (winid, const char *)); STATIC_DCL int FDECL(dump_select_menu, (winid, int, MENU_ITEM_P **)); STATIC_DCL void FDECL(dump_putstr, (winid, int, const char *)); @@ -145,14 +146,22 @@ static struct winlink *chain = 0; static struct winlink * wl_new() { - return calloc(1, sizeof(struct winlink)); + struct winlink *wl = (struct winlink *) alloc(sizeof *wl); + + wl->nextlink = 0; + wl->wincp = 0; + wl->linkdata = 0; + + return wl; } + static void wl_addhead(struct winlink *wl) { wl->nextlink = chain; chain = wl; } + static void wl_addtail(struct winlink *wl) { @@ -255,24 +264,28 @@ const char *s; if (!winchoices[0].procs) { raw_printf("No window types?"); - exit(EXIT_FAILURE); + nh_terminate(EXIT_FAILURE); } if (!winchoices[1].procs) { - config_error_add("Window type %s not recognized. The only choice is: %s", - s, winchoices[0].procs->name); + config_error_add( + "Window type %s not recognized. The only choice is: %s", + s, winchoices[0].procs->name); } else { char buf[BUFSZ]; boolean first = TRUE; + buf[0] = '\0'; for (i = 0; winchoices[i].procs; i++) { if ('+' == winchoices[i].procs->name[0]) continue; if ('-' == winchoices[i].procs->name[0]) continue; - Sprintf(eos(buf), "%s%s", first ? "" : ",", winchoices[i].procs->name); + Sprintf(eos(buf), "%s%s", + first ? "" : ", ", winchoices[i].procs->name); first = FALSE; } - config_error_add("Window type %s not recognized. Choices are: %s", s, buf); + config_error_add("Window type %s not recognized. Choices are: %s", + s, buf); } if (windowprocs.win_raw_print == def_raw_print) @@ -291,6 +304,7 @@ const char *s; continue; if (!strcmpi(s, winchoices[i].procs->name)) { struct winlink *p = wl_new(); + p->wincp = &winchoices[i]; wl_addtail(p); /* NB: The ini_routine() will be called during commit. */ @@ -307,7 +321,7 @@ const char *s; raw_printf(" %s", winchoices[i].procs->name); } - exit(EXIT_FAILURE); + nh_terminate(EXIT_FAILURE); } void @@ -494,7 +508,8 @@ static short FDECL(hup_set_font_name, (winid, char *)); #endif static char *NDECL(hup_get_color_string); #endif /* CHANGE_COLOR */ -static void FDECL(hup_status_update, (int, genericptr_t, int, int, int, unsigned long *)); +static void FDECL(hup_status_update, (int, genericptr_t, int, int, int, + unsigned long *)); static int NDECL(hup_int_ndecl); static void NDECL(hup_void_ndecl); diff --git a/win/chain/wc_chainin.c b/win/chain/wc_chainin.c index bd0a11827..00cd7e75f 100644 --- a/win/chain/wc_chainin.c +++ b/win/chain/wc_chainin.c @@ -27,23 +27,26 @@ void *me; void *nextprocs; void *nextdata; { + struct chainin_data *tdp = 0; + switch (cmd) { - case WINCHAIN_ALLOC: { - struct chainin_data *tdp = calloc(1, sizeof(struct chainin_data)); + case WINCHAIN_ALLOC: + tdp = (struct chainin_data *) alloc(sizeof *tdp); + tdp->nprocs = 0; + tdp->ndata = 0; tdp->linknum = n; - cibase = tdp; - return tdp; - } - case WINCHAIN_INIT: { - struct chainin_data *tdp = me; + cibase = 0; + break; + case WINCHAIN_INIT: + tdp = me; tdp->nprocs = nextprocs; tdp->ndata = nextdata; - return tdp; - } + break; default: - raw_printf("chainin_procs_chain: bad cmd\n"); - exit(EXIT_FAILURE); + panic("chainin_procs_chain: bad cmd\n"); + /*NOTREACHED*/ } + return tdp; } /* XXX if we don't need this, take it out of the table */ diff --git a/win/chain/wc_chainout.c b/win/chain/wc_chainout.c index af964438c..18af49e17 100644 --- a/win/chain/wc_chainout.c +++ b/win/chain/wc_chainout.c @@ -10,7 +10,7 @@ struct chainout_data { struct window_procs *nprocs; #if 0 - void *ndata; + void *ndata; #endif int linknum; @@ -24,21 +24,23 @@ void *me; void *nextprocs; void *nextdata UNUSED; { + struct chainout_data *tdp = 0; + switch (cmd) { - case WINCHAIN_ALLOC: { - struct chainout_data *tdp = calloc(1, sizeof(struct chainout_data)); + case WINCHAIN_ALLOC: + tdp = (struct chainout_data *) alloc(sizeof *tdp); + tdp->nprocs = 0; tdp->linknum = n; - return tdp; - } - case WINCHAIN_INIT: { - struct chainout_data *tdp = me; + break; + case WINCHAIN_INIT: + tdp = me; tdp->nprocs = nextprocs; - return tdp; - } + break; default: - raw_printf("chainout_procs_chain: bad cmd\n"); - exit(EXIT_FAILURE); + panic("chainout_procs_chain: bad cmd\n"); + /*NOTREACHED*/ } + return tdp; } /* XXX if we don't need this, take it out of the table */ diff --git a/win/chain/wc_trace.c b/win/chain/wc_trace.c index ec81f0a8b..6da9a9b83 100644 --- a/win/chain/wc_trace.c +++ b/win/chain/wc_trace.c @@ -48,22 +48,25 @@ void *me; void *nextprocs; void *nextdata; { + struct trace_data *tdp = 0; + switch (cmd) { - case WINCHAIN_ALLOC: { - struct trace_data *tdp = calloc(1, sizeof(struct trace_data)); + case WINCHAIN_ALLOC: + tdp = (struct trace_data *) alloc(sizeof *tdp); + tdp->nprocs = 0; + tdp->ndata = 0; tdp->linknum = n; - return tdp; - } - case WINCHAIN_INIT: { - struct trace_data *tdp = me; + break; + case WINCHAIN_INIT: + tdp = me; tdp->nprocs = nextprocs; tdp->ndata = nextdata; - return tdp; - } + break; default: - raw_printf("trace_procs_chain: bad cmd\n"); - exit(EXIT_FAILURE); + panic("trace_procs_chain: bad cmd\n"); + /*NOTREACHED*/ } + return tdp; } void @@ -71,20 +74,22 @@ trace_procs_init(dir) int dir; { char fname[200]; + long pid; /* processors shouldn't need this test, but just in case */ if (dir != WININIT) return; - sprintf(fname, "%s/tlog.%d", HACKDIR, getpid()); + pid = (long) getpid(); + Sprintf(fname, "%s/tlog.%ld", HACKDIR, pid); wc_tracelogf = fopen(fname, "w"); - if (wc_tracelogf == NULL) { + if (!wc_tracelogf) { fprintf(stderr, "Can't open trace log file %s: %s\n", fname, strerror(errno)); - exit(EXIT_FAILURE); + nh_terminate(EXIT_FAILURE); } - setvbuf(wc_tracelogf, (char *) NULL, _IONBF, 0); - fprintf(wc_tracelogf, "Trace log started for pid %d\n", getpid()); + setvbuf(wc_tracelogf, (char *) 0, _IONBF, 0); + fprintf(wc_tracelogf, "Trace log started for pid %ld\n", pid); indent_level = 0; } @@ -769,7 +774,7 @@ char *bufp; } if (bufp) { - fprintf(wc_tracelogf, "%p)\n", bufp); + fprintf(wc_tracelogf, "%s)\n", fmt_ptr((genericptr_t) bufp)); } else { fprintf(wc_tracelogf, "NULL)\n"); } @@ -785,7 +790,7 @@ void *vp; { struct trace_data *tdp = vp; int rv; - int ecl_size; + int ecl_size = 0; /* this is ugly, but the size isn't exposed */ const struct ext_func_tab *efp; @@ -1095,7 +1100,8 @@ unsigned long *colormasks; ptr, chg, percent); PRE; - (*tdp->nprocs->win_status_update)(tdp->ndata, idx, ptr, chg, percent, color, colormasks); + (*tdp->nprocs->win_status_update)(tdp->ndata, idx, ptr, chg, percent, + color, colormasks); POST; }