From 01566f2b49c33e865361da66e01b61f4c7bbc05e Mon Sep 17 00:00:00 2001 From: rlar Date: Tue, 2 Nov 2010 17:07:57 +0000 Subject: [PATCH] add casts to make `int' versus `size_t' conversions explicit --- ChangeLog | 43 +++++++++++++++++++ src/ciderlib/oned/oneprint.c | 2 +- src/ciderlib/support/database.c | 2 +- src/ciderlib/twod/twoprint.c | 4 +- src/frontend/com_ahelp.c | 2 +- src/frontend/com_display.c | 2 +- src/frontend/com_help.c | 2 +- src/frontend/com_let.c | 4 +- src/frontend/define.c | 4 +- src/frontend/device.c | 2 +- src/frontend/help/readhelp.c | 2 +- src/frontend/outitf.c | 6 +-- src/frontend/plotting/plotcurv.c | 6 +-- src/frontend/subckt.c | 6 +-- src/frontend/terminal.c | 2 +- src/frontend/variable.c | 2 +- src/frontend/vectors.c | 10 ++--- src/maths/poly/interpolate.c | 4 +- src/maths/poly/polyfit.c | 6 +-- src/spicelib/analysis/dctran.c | 2 +- src/spicelib/analysis/dctrcurv.c | 2 +- src/spicelib/devices/cpl/cplsetup.c | 12 +++--- src/spicelib/devices/ndev/ndevset.c | 2 +- src/spicelib/parser/inp2r.c | 2 +- src/spicelib/parser/inpgstr.c | 2 +- src/spicelib/parser/inpgtok.c | 8 ++-- src/spicelib/parser/inpptree.c | 2 +- src/xspice/cmpp/ifs_yacc.y | 4 +- src/xspice/cmpp/pp_lst.c | 8 ++-- src/xspice/cmpp/writ_ifs.c | 2 +- src/xspice/icm/analog/oneshot/cfunc.mod | 4 +- src/xspice/icm/analog/pwl/cfunc.mod | 4 +- src/xspice/icm/analog/s_xfer/cfunc.mod | 24 +++++------ src/xspice/icm/analog/sine/cfunc.mod | 4 +- src/xspice/icm/analog/square/cfunc.mod | 4 +- src/xspice/icm/analog/triangle/cfunc.mod | 4 +- src/xspice/icm/digital/d_osc/cfunc.mod | 4 +- src/xspice/icm/digital/d_state/cfunc.mod | 8 ++-- .../icm/spice2poly/icm_spice2poly/cfunc.mod | 8 ++-- src/xspice/icm/xtradev/core/cfunc.mod | 4 +- src/xspice/ipc/ipc.c | 2 +- 41 files changed, 134 insertions(+), 93 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5dba71d14..65a30f413 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,46 @@ +2010-11-02 Robert Larice + * src/ciderlib/oned/oneprint.c , + * src/ciderlib/support/database.c , + * src/ciderlib/twod/twoprint.c , + * src/frontend/com_ahelp.c , + * src/frontend/com_display.c , + * src/frontend/com_help.c , + * src/frontend/com_let.c , + * src/frontend/define.c , + * src/frontend/device.c , + * src/frontend/help/readhelp.c , + * src/frontend/outitf.c , + * src/frontend/plotting/plotcurv.c , + * src/frontend/subckt.c , + * src/frontend/terminal.c , + * src/frontend/variable.c , + * src/frontend/vectors.c , + * src/maths/poly/interpolate.c , + * src/maths/poly/polyfit.c , + * src/spicelib/analysis/dctran.c , + * src/spicelib/analysis/dctrcurv.c , + * src/spicelib/devices/cpl/cplsetup.c , + * src/spicelib/devices/ndev/ndevset.c , + * src/spicelib/parser/inp2r.c , + * src/spicelib/parser/inpgstr.c , + * src/spicelib/parser/inpgtok.c , + * src/spicelib/parser/inpptree.c , + * src/xspice/cmpp/ifs_yacc.y , + * src/xspice/cmpp/pp_lst.c , + * src/xspice/cmpp/writ_ifs.c , + * src/xspice/icm/analog/oneshot/cfunc.mod , + * src/xspice/icm/analog/pwl/cfunc.mod , + * src/xspice/icm/analog/s_xfer/cfunc.mod , + * src/xspice/icm/analog/sine/cfunc.mod , + * src/xspice/icm/analog/square/cfunc.mod , + * src/xspice/icm/analog/triangle/cfunc.mod , + * src/xspice/icm/digital/d_osc/cfunc.mod , + * src/xspice/icm/digital/d_state/cfunc.mod , + * src/xspice/icm/spice2poly/icm_spice2poly/cfunc.mod , + * src/xspice/icm/xtradev/core/cfunc.mod , + * src/xspice/ipc/ipc.c : + casts, to make int <-> size_t conversions explicit + 2010-11-01 Holger Vogt * compile_min.sh: exit upon make errors diff --git a/src/ciderlib/oned/oneprint.c b/src/ciderlib/oned/oneprint.c index 76174964d..e3978134f 100644 --- a/src/ciderlib/oned/oneprint.c +++ b/src/ciderlib/oned/oneprint.c @@ -303,7 +303,7 @@ ONEprnSolution(FILE *file, ONEdevice *pDevice, OUTPcard *output) if (output->OUTPmup) { data[numVars++] = mup; } - fwrite((char *) data, sizeof(double), numVars, file); + fwrite(data, sizeof(double), (size_t) numVars, file); } FREE(nodeArray); } diff --git a/src/ciderlib/support/database.c b/src/ciderlib/support/database.c index 737ff305d..095e113ec 100644 --- a/src/ciderlib/support/database.c +++ b/src/ciderlib/support/database.c @@ -38,7 +38,7 @@ DBgetData(struct plot *plot, char *name, int lengthWanted) data = TMALLOC(double, v->v_length); if (isreal(v)) { - bcopy(v->v_realdata, data, sizeof (double) * v->v_length); + bcopy(v->v_realdata, data, sizeof (double) * (size_t) v->v_length); } else { for (i=0; i < v->v_length; i++) { data[i] = realpart(&v->v_compdata[i]); diff --git a/src/ciderlib/twod/twoprint.c b/src/ciderlib/twod/twoprint.c index 465c47b86..ea5d2179c 100644 --- a/src/ciderlib/twod/twoprint.c +++ b/src/ciderlib/twod/twoprint.c @@ -308,14 +308,14 @@ TWOprnSolution(FILE *file, TWOdevice *pDevice, OUTPcard *output) if (output->OUTPmup) { data[numVars++] = mup; } - fwrite((char *) data, sizeof(double), numVars, file); + fwrite(data, sizeof(double), (size_t) numVars, file); } else { for (index = 0; index < output->OUTPnumVars; index++) { data[index] = 0.0; } data[0] = yScale[yIndex] * 1e-2; data[1] = xScale[xIndex] * 1e-2; - fwrite((char *) data, sizeof(double), numVars, file); + fwrite(data, sizeof(double), (size_t) numVars, file); } } } diff --git a/src/frontend/com_ahelp.c b/src/frontend/com_ahelp.c index 57f558c19..15d618b84 100644 --- a/src/frontend/com_ahelp.c +++ b/src/frontend/com_ahelp.c @@ -66,7 +66,7 @@ com_ahelp(wordlist *wl) for (n = 0; cp_coms[n].co_func != NULL; n++) { cc[n] = &cp_coms[n]; } - qsort(cc, n, sizeof(struct comm *), hcomp); + qsort(cc, (size_t) n, sizeof(struct comm *), hcomp); /* filter the commands */ for (i=0; i< n; i++) { diff --git a/src/frontend/com_display.c b/src/frontend/com_display.c index 8072ab946..63f2fe2e0 100644 --- a/src/frontend/com_display.c +++ b/src/frontend/com_display.c @@ -65,7 +65,7 @@ com_display(wordlist *wl) for (d = plot_cur->pl_dvecs, i = 0; d; d = d->v_next, i++) dvs[i] = d; if (!cp_getvar("nosort", CP_BOOL, NULL)) - qsort(dvs, len, sizeof (struct dvec *), dcomp); + qsort(dvs, (size_t) len, sizeof (struct dvec *), dcomp); out_printf("Title: %s\n", plot_cur->pl_title); out_printf("Name: %s (%s)\nDate: %s\n\n", diff --git a/src/frontend/com_help.c b/src/frontend/com_help.c index 9a1ad385a..fdd5d9bde 100644 --- a/src/frontend/com_help.c +++ b/src/frontend/com_help.c @@ -42,7 +42,7 @@ com_help(wordlist *wl) /* Sort the commands */ for (numcoms = 0; cp_coms[numcoms].co_func != NULL; numcoms++) ccc[numcoms] = &cp_coms[numcoms]; - qsort(ccc, numcoms, sizeof (struct comm *), hcomp); + qsort(ccc, (size_t) numcoms, sizeof (struct comm *), hcomp); for (i = 0; i < numcoms; i++) { if ((ccc[i]->co_spiceonly && ft_nutmeg) || diff --git a/src/frontend/com_let.c b/src/frontend/com_let.c index 81fcf0bff..99ca8b860 100644 --- a/src/frontend/com_let.c +++ b/src/frontend/com_let.c @@ -213,10 +213,10 @@ com_let(wordlist *wl) goto quit; } else if (isreal(t)) { bcopy(t->v_realdata, n->v_realdata + offset, - length * sizeof (double)); + (size_t) length * sizeof (double)); } else { bcopy(t->v_compdata, n->v_compdata + offset, - length * sizeof(ngcomplex_t)); + (size_t) length * sizeof(ngcomplex_t)); } n->v_minsignal = 0.0; /* How do these get reset ??? */ diff --git a/src/frontend/define.c b/src/frontend/define.c index f9b4a4bf3..ec2b6b37d 100644 --- a/src/frontend/define.c +++ b/src/frontend/define.c @@ -167,12 +167,12 @@ savetree(struct pnode *pn) pn->pn_value->v_realdata = TMALLOC(double, d->v_length); bcopy(d->v_realdata, pn->pn_value->v_realdata, - sizeof (double) * d->v_length); + sizeof (double) * (size_t) d->v_length); } else { pn->pn_value->v_compdata = TMALLOC(ngcomplex_t, d->v_length); bcopy(d->v_compdata, pn->pn_value->v_compdata, - sizeof(ngcomplex_t) * d->v_length); + sizeof(ngcomplex_t) * (size_t) d->v_length); } } } else if (pn->pn_op) { diff --git a/src/frontend/device.c b/src/frontend/device.c index 5283d3949..ed060be6e 100644 --- a/src/frontend/device.c +++ b/src/frontend/device.c @@ -920,7 +920,7 @@ com_alter_common(wordlist *wl, int do_model) arglist[0] = TMALLOC(char, i + 1); arglist[2] = TMALLOC(char, strlen(&argument[i + 1]) + 1); /* copy argument */ - strncpy(arglist[0],argument,i); + strncpy(arglist[0], argument, (size_t) i); arglist[0][i] = '\0'; /* copy equal sign */ arglist[1] = copy("="); diff --git a/src/frontend/help/readhelp.c b/src/frontend/help/readhelp.c index 2c2a828d0..cae961220 100644 --- a/src/frontend/help/readhelp.c +++ b/src/frontend/help/readhelp.c @@ -189,7 +189,7 @@ static toplink *getsubtoplink(char **ss) tl->place = alloc(fplace); tl->place->filename = strncpy( TMALLOC(char, tmp - s + 1), - s, (tmp - s)); + s, (size_t) (tmp - s)); tl->place->filename[tmp - s] = '\0'; strtolower(tl->place->filename); diff --git a/src/frontend/outitf.c b/src/frontend/outitf.c index c05df19f8..146a9fc11 100644 --- a/src/frontend/outitf.c +++ b/src/frontend/outitf.c @@ -978,12 +978,12 @@ plotAddRealValue(dataDesc *desc, double value) if (isreal(v)) { v->v_realdata = (double *) newrealloc(v->v_realdata, - sizeof (double) * (v->v_length + 1)); + sizeof(double) * (size_t) (v->v_length + 1)); v->v_realdata[v->v_length] = value; } else { /* a real parading as a VF_COMPLEX */ v->v_compdata = (ngcomplex_t *) newrealloc(v->v_compdata, - sizeof(ngcomplex_t) * (v->v_length + 1)); + sizeof(ngcomplex_t) * (size_t) (v->v_length + 1)); v->v_compdata[v->v_length].cx_real = value; v->v_compdata[v->v_length].cx_imag = (double) 0; } @@ -999,7 +999,7 @@ plotAddComplexValue(dataDesc *desc, IFcomplex value) struct dvec *v = desc->vec; v->v_compdata = (ngcomplex_t *) newrealloc(v->v_compdata, - sizeof(ngcomplex_t) * (v->v_length + 1)); + sizeof(ngcomplex_t) * (size_t) (v->v_length + 1)); v->v_compdata[v->v_length].cx_real = value.real; v->v_compdata[v->v_length].cx_imag = value.imag; v->v_length++; diff --git a/src/frontend/plotting/plotcurv.c b/src/frontend/plotting/plotcurv.c index 465b3e89b..296f9e96f 100644 --- a/src/frontend/plotting/plotcurv.c +++ b/src/frontend/plotting/plotcurv.c @@ -217,14 +217,12 @@ ft_graf(struct dvec *v, struct dvec *xs, bool nostart) /* Plot the first degree segments... */ if (isreal(v)) - bcopy(v->v_realdata, ydata, - (degree + 1) * sizeof (double)); + bcopy(v->v_realdata, ydata, (size_t)(degree + 1) * sizeof(double)); else for (i = 0; i <= degree; i++) ydata[i] = realpart(&v->v_compdata[i]); if (isreal(xs)) - bcopy(xs->v_realdata, xdata, - (degree + 1) * sizeof (double)); + bcopy(xs->v_realdata, xdata, (size_t)(degree + 1) * sizeof(double)); else for (i = 0; i <= degree; i++) xdata[i] = realpart(&xs->v_compdata[i]); diff --git a/src/frontend/subckt.c b/src/frontend/subckt.c index cd49b911d..8a7c6568e 100644 --- a/src/frontend/subckt.c +++ b/src/frontend/subckt.c @@ -253,7 +253,7 @@ inp_subcktexpand(struct line *deck) i=0; t=s; for (/*s*/; *s && !isspace(*s); s++) i++; - strncpy(node[numgnode],t,i); + strncpy(node[numgnode], t, (size_t) i); if(i>0 && t[i-1] != '\0') node[numgnode][i] = '\0'; while (isspace(*s)) s++; @@ -803,7 +803,7 @@ bxx_printf(struct bxx_buffer *t, const char *fmt, ...) int ret; int size = t->limit - t->dst; va_start(ap, fmt); - ret = vsnprintf(t->dst, size, fmt, ap); + ret = vsnprintf(t->dst, (size_t) size, fmt, ap); va_end(ap); if(ret == -1) { bxx_extend(t, bxx_chunksize); @@ -1950,7 +1950,7 @@ devmodtranslate(struct line *deck, char *subname) dot_char++; j++; } } - if ( strncmp( name, wlsub->wl_word, i - j ) == 0 ) { + if ( strncmp( name, wlsub->wl_word, (size_t) (i - j) ) == 0 ) { (void) sprintf(buffer + strlen(buffer), "%s:%s ", subname, name); found = TRUE; diff --git a/src/frontend/terminal.c b/src/frontend/terminal.c index 07c6edbb4..9efd23bf7 100644 --- a/src/frontend/terminal.c +++ b/src/frontend/terminal.c @@ -143,7 +143,7 @@ outbufputc(void) if (ourbuf.count != BUFSIZ) { fputs(staticbuf, cp_out); - memset(staticbuf, 0, BUFSIZ-ourbuf.count); + memset(staticbuf, 0, (size_t) (BUFSIZ - ourbuf.count)); ourbuf.count = BUFSIZ; ourbuf.ptr = staticbuf; } diff --git a/src/frontend/variable.c b/src/frontend/variable.c index dab947549..15901e839 100644 --- a/src/frontend/variable.c +++ b/src/frontend/variable.c @@ -913,7 +913,7 @@ cp_vprint(void) vars[i].x_char = '+'; } - qsort(vars, i, sizeof (struct xxx), vcmp); + qsort(vars, (size_t) i, sizeof (struct xxx), vcmp); for (j = 0; j < i; j++) { if (j && eq(vars[j].x_v->va_name, vars[j - 1].x_v->va_name)) diff --git a/src/frontend/vectors.c b/src/frontend/vectors.c index f6a1acd6b..d40c0b693 100644 --- a/src/frontend/vectors.c +++ b/src/frontend/vectors.c @@ -198,7 +198,7 @@ sortvecs(struct dvec *d) for (t = d, i = 0; t; t = t->v_link2) array[i++] = t; - qsort(array, i, sizeof (struct dvec *), veccmp); + qsort(array, (size_t) i, sizeof (struct dvec *), veccmp); /* Now string everything back together... */ for (j = 0; j < i - 1; j++) @@ -645,13 +645,13 @@ vec_copy(struct dvec *v) if (isreal(v)) { nv->v_realdata = TMALLOC(double, v->v_length); bcopy(v->v_realdata, nv->v_realdata, - sizeof (double) * v->v_length); + sizeof (double) * (size_t) v->v_length); nv->v_compdata = NULL; } else { nv->v_realdata = NULL; nv->v_compdata = TMALLOC(ngcomplex_t, v->v_length); bcopy(v->v_compdata, nv->v_compdata, - sizeof(ngcomplex_t) * v->v_length); + sizeof(ngcomplex_t) * (size_t) v->v_length); } nv->v_minsignal = v->v_minsignal; @@ -1063,10 +1063,10 @@ vec_mkfamily(struct dvec *v) if (isreal(v)) { d->v_realdata = TMALLOC(double, size); - bcopy(v->v_realdata + size*j, d->v_realdata, size*sizeof(double)); + bcopy(v->v_realdata + size*j, d->v_realdata, (size_t) size * sizeof(double)); } else { d->v_compdata = TMALLOC(ngcomplex_t, size); - bcopy(v->v_compdata + size*j, d->v_compdata, size*sizeof(ngcomplex_t)); + bcopy(v->v_compdata + size*j, d->v_compdata, (size_t) size * sizeof(ngcomplex_t)); } /* Add one to the counter. */ (void) incindex(count, v->v_numdims - 1, v->v_dims, v->v_numdims); diff --git a/src/maths/poly/interpolate.c b/src/maths/poly/interpolate.c index 0d3fdabf8..0544d2670 100644 --- a/src/maths/poly/interpolate.c +++ b/src/maths/poly/interpolate.c @@ -61,8 +61,8 @@ ft_interpolate(double *data, double *ndata, double *oscale, int olen, ydata = TMALLOC(double, degree + 1); /* Deal with the first degree pieces. */ - bcopy(data, ydata, (degree + 1) * sizeof (double)); - bcopy(oscale, xdata, (degree + 1) * sizeof (double)); + bcopy(data, ydata, (size_t) (degree + 1) * sizeof (double)); + bcopy(oscale, xdata, (size_t) (degree + 1) * sizeof (double)); while (!ft_polyfit(xdata, ydata, result, degree, scratch)) { /* If it doesn't work this time, bump the interpolation diff --git a/src/maths/poly/polyfit.c b/src/maths/poly/polyfit.c index 42373fa31..ffde6a898 100644 --- a/src/maths/poly/polyfit.c +++ b/src/maths/poly/polyfit.c @@ -17,9 +17,9 @@ ft_polyfit(double *xdata, double *ydata, double *result, double *mat2 = scratch + n * n; /* XXX These guys are hacks! */ double d; - memset((char *) result, 0, n * sizeof(double)); - memset((char *) mat1, 0, n * n * sizeof (double)); - memcpy((char *) mat2, (char *) ydata, n * sizeof (double)); + memset(result, 0, (size_t) (n) * sizeof(double)); + memset(mat1, 0, (size_t) (n * n) * sizeof(double)); + memcpy(mat2, ydata, (size_t) (n) * sizeof(double)); /* Fill in the matrix with x^k for 0 <= k <= degree for each point */ l = 0; diff --git a/src/spicelib/analysis/dctran.c b/src/spicelib/analysis/dctran.c index 6701c83c6..c094f67fa 100644 --- a/src/spicelib/analysis/dctran.c +++ b/src/spicelib/analysis/dctran.c @@ -289,7 +289,7 @@ DCtran(CKTcircuit *ckt, /* modeinittran set here */ ckt->CKTag[0]=ckt->CKTag[1]=0; bcopy(ckt->CKTstate0, ckt->CKTstate1, - ckt->CKTnumStates*sizeof(double)); + (size_t) ckt->CKTnumStates * sizeof(double)); #ifdef WANT_SENSE2 if(ckt->CKTsenInfo && (ckt->CKTsenInfo->SENmode & TRANSEN)){ diff --git a/src/spicelib/analysis/dctrcurv.c b/src/spicelib/analysis/dctrcurv.c index 878e5a6f4..0cbe34b13 100644 --- a/src/spicelib/analysis/dctrcurv.c +++ b/src/spicelib/analysis/dctrcurv.c @@ -479,7 +479,7 @@ resume: if(firstTime) { firstTime=0; bcopy(ckt->CKTstate0, ckt->CKTstate1, - ckt->CKTnumStates*sizeof(double)); + (size_t) ckt->CKTnumStates * sizeof(double)); } nextstep:; diff --git a/src/spicelib/devices/cpl/cplsetup.c b/src/spicelib/devices/cpl/cplsetup.c index 03eb80575..21f7513da 100644 --- a/src/spicelib/devices/cpl/cplsetup.c +++ b/src/spicelib/devices/cpl/cplsetup.c @@ -536,19 +536,19 @@ new_memory(int dim, int deg, int deg_o) for (i = 0; i < dim; i++) for (j = 0; j < dim; j++) - SiSv_1[i][j] = (double *) calloc(deg_o+1, sizeof(double)); + SiSv_1[i][j] = (double *) calloc((size_t) (deg_o+1), sizeof(double)); for (i = 0; i < dim; i++) for (j = 0; j < dim; j++) - Sip[i][j] = (double *) calloc(deg_o+1, sizeof(double)); + Sip[i][j] = (double *) calloc((size_t) (deg_o+1), sizeof(double)); for (i = 0; i < dim; i++) for (j = 0; j < dim; j++) - Si_1p[i][j] = (double *) calloc(deg_o+1, sizeof(double)); + Si_1p[i][j] = (double *) calloc((size_t) (deg_o+1), sizeof(double)); for (i = 0; i < dim; i++) for (j = 0; j < dim; j++) - Sv_1p[i][j] = (double *) calloc(deg_o+1, sizeof(double)); + Sv_1p[i][j] = (double *) calloc((size_t) (deg_o+1), sizeof(double)); for (i = 0; i < dim; i++) W[i] = (double *) calloc(MAX_DEG, sizeof(double)); @@ -1475,14 +1475,14 @@ matrix_p_mult( for (i = 0; i < dim; i++) for (j = 0; j < dim; j++) { - p = T[i][j] = (double *) calloc(deg_o+1, sizeof(double)); + p = T[i][j] = (double *) calloc((size_t) (deg_o+1), sizeof(double)); mult_p(B[i][j], D[i], p, deg, deg_o, deg_o); } for (i = 0; i < dim; i++) for (j = 0; j < dim; j++) for (k = 0; k < dim; k++) { p = X[i][j].Poly[k] = - (double *) calloc(deg_o+1, sizeof(double)); + (double *) calloc((size_t) (deg_o+1), sizeof(double)); mult_p(A[i][k], T[k][j], p, deg, deg_o, deg_o); t1 = X[i][j].C_0[k] = p[0]; if (t1 != 0.0) { diff --git a/src/spicelib/devices/ndev/ndevset.c b/src/spicelib/devices/ndev/ndevset.c index 9f46ec793..dd04f0027 100644 --- a/src/spicelib/devices/ndev/ndevset.c +++ b/src/spicelib/devices/ndev/ndevset.c @@ -129,7 +129,7 @@ int NDEVmodelConnect(NDEVmodel *inModel) various reasons. Just memcpy it into the sockaddr_in structure. */ memcpy(&sa.sin_addr, hostlist->h_addr_list[0], - hostlist->h_length); + (size_t) hostlist->h_length); /* This is an Internet socket. */ sa.sin_family = AF_INET; /* Connect! */ diff --git a/src/spicelib/parser/inp2r.c b/src/spicelib/parser/inp2r.c index 7a40bef45..c9e74e5a9 100644 --- a/src/spicelib/parser/inp2r.c +++ b/src/spicelib/parser/inp2r.c @@ -135,7 +135,7 @@ void INP2R(CKTcircuit *ckt, INPtables * tab, card * current) /* copy first part of line */ i -= strlen(t); - strncpy(line,current->line,i); + strncpy(line, current->line, (size_t) i); line[i]=0; /* terminate */ /* add "tc2=" */ diff --git a/src/spicelib/parser/inpgstr.c b/src/spicelib/parser/inpgstr.c index d0270d627..88beb15b3 100644 --- a/src/spicelib/parser/inpgstr.c +++ b/src/spicelib/parser/inpgstr.c @@ -51,7 +51,7 @@ int INPgetStr(char **line, char **token, int gobble) *token = TMALLOC(char, 1 + point - *line); if (!*token) return (E_NOMEM); - (void) strncpy(*token, *line, point - *line); + (void) strncpy(*token, *line, (size_t) (point - *line)); *(*token + (point - *line)) = '\0'; *line = point; diff --git a/src/spicelib/parser/inpgtok.c b/src/spicelib/parser/inpgtok.c index f98f80387..f1b8a9a37 100644 --- a/src/spicelib/parser/inpgtok.c +++ b/src/spicelib/parser/inpgtok.c @@ -101,7 +101,7 @@ int INPgetTok(char **line, char **token, int gobble) *token = TMALLOC(char, 1 + diffpoints); if (!*token) return (E_NOMEM); - (void) strncpy(*token, *line, diffpoints); + (void) strncpy(*token, *line, (size_t) diffpoints); *(*token + diffpoints) = '\0'; *line = point; /* @@ -199,7 +199,7 @@ int INPgetNetTok(char **line, char **token, int gobble) *token = TMALLOC(char, 1 + diffpoints); if (!*token) return (E_NOMEM); - (void) strncpy(*token, *line, diffpoints); + (void) strncpy(*token, *line, (size_t) diffpoints); *(*token + diffpoints) = '\0'; *line = point; @@ -331,7 +331,7 @@ int INPgetUTok(char **line, char **token, int gobble) *token = TMALLOC(char, 1 + point - *line); if (!*token) return (E_NOMEM); - (void) strncpy(*token, *line, point - *line); + (void) strncpy(*token, *line, (size_t) (point - *line)); *(*token + (point - *line)) = '\0'; /* gobble garbage to next token */ for (; *point != '\0'; point++) { @@ -458,7 +458,7 @@ int INPgetU2Tok(char **line, char **token, int gobble) *token = TMALLOC(char, 1 + point - *line); if (!*token) return (E_NOMEM); - (void) strncpy(*token, *line, point - *line); + (void) strncpy(*token, *line, (size_t) (point - *line)); *(*token + (point - *line)) = '\0'; /* gobble garbage to next token */ for (; *point != '\0'; point++) { diff --git a/src/spicelib/parser/inpptree.c b/src/spicelib/parser/inpptree.c index 691f73bdb..73d9e5eb4 100644 --- a/src/spicelib/parser/inpptree.c +++ b/src/spicelib/parser/inpptree.c @@ -1166,7 +1166,7 @@ int PTlex (YYSTYPE *lvalp, char **line) if (index(specials, *s)) break; tmp = TMALLOC(char, s - sbuf + 1); - strncpy(tmp, sbuf, s - sbuf); + strncpy(tmp, sbuf, (size_t) (s - sbuf)); tmp[s - sbuf] = '\0'; lvalp->str = tmp; sbuf = s; diff --git a/src/xspice/cmpp/ifs_yacc.y b/src/xspice/cmpp/ifs_yacc.y index c1a9eaad9..daa9dc99d 100755 --- a/src/xspice/cmpp/ifs_yacc.y +++ b/src/xspice/cmpp/ifs_yacc.y @@ -278,9 +278,9 @@ assign_ctype_list (Conn_Info_t *conn, Ctype_List_t *ctype_list ) for (p = ctype_list; p; p = p->next) { conn->num_allowed_types++; } - conn->allowed_type = (char**) calloc (conn->num_allowed_types, + conn->allowed_type = (char**) calloc ((size_t) conn->num_allowed_types, sizeof (char*)); - conn->allowed_port_type = (Port_Type_t*) calloc (conn->num_allowed_types, + conn->allowed_port_type = (Port_Type_t*) calloc ((size_t) conn->num_allowed_types, sizeof (Port_Type_t)); if (! (conn->allowed_type && conn->allowed_port_type)) { fatal ("Could not allocate memory"); diff --git a/src/xspice/cmpp/pp_lst.c b/src/xspice/cmpp/pp_lst.c index aa01b72c0..c9551046b 100755 --- a/src/xspice/cmpp/pp_lst.c +++ b/src/xspice/cmpp/pp_lst.c @@ -296,7 +296,7 @@ static Status_t read_modpath( if(n == 0) model = (Model_Info_t *) malloc(sizeof(Model_Info_t)); else - model = (Model_Info_t *) realloc(model, (n + 1) * sizeof(Model_Info_t)); + model = (Model_Info_t *) realloc(model, (size_t) (n + 1) * sizeof(Model_Info_t)); model[n].path_name = NULL; model[n].spice_name = NULL; model[n].cfunc_name = NULL; @@ -304,7 +304,7 @@ static Status_t read_modpath( model[n].cfunc_unique = TRUE; /* Put pathname into info structure */ - model[n].path_name = (char *) malloc(len+1); + model[n].path_name = (char *) malloc((size_t) (len+1)); strcpy(model[n].path_name, path); /* Increment count of paths read */ @@ -417,13 +417,13 @@ static Status_t read_udnpath( if(n == 0) node = (Node_Info_t *) malloc(sizeof(Node_Info_t)); else - node = (Node_Info_t *) realloc(node, (n + 1) * sizeof(Node_Info_t)); + node = (Node_Info_t *) realloc(node, (size_t) (n + 1) * sizeof(Node_Info_t)); node[n].path_name = NULL; node[n].node_name = NULL; node[n].unique = TRUE; /* Put pathname into info structure */ - node[n].path_name = (char *) malloc(len+1); + node[n].path_name = (char *) malloc((size_t) (len+1)); strcpy(node[n].path_name, path); /* Increment count of paths read */ diff --git a/src/xspice/cmpp/writ_ifs.c b/src/xspice/cmpp/writ_ifs.c index 652d5243e..94fcd8c86 100755 --- a/src/xspice/cmpp/writ_ifs.c +++ b/src/xspice/cmpp/writ_ifs.c @@ -1215,7 +1215,7 @@ static char *value_to_str(Data_Type_t type, Value_t value) /* be careful, the string could conceivably be very long... */ str_len = strlen(value.svalue); if((str_len + BASE_STR_LEN) > max_len) { - str = (char *) realloc(str, (max_len + str_len +1)); + str = (char *) realloc(str, (size_t) (max_len + str_len + 1)); max_len += str_len; } sprintf(str, "{MIF_FALSE, 0, 0.0, {0.0, 0.0}, \"%s\"}", value.svalue); diff --git a/src/xspice/icm/analog/oneshot/cfunc.mod b/src/xspice/icm/analog/oneshot/cfunc.mod index 5172982e3..610b56e26 100644 --- a/src/xspice/icm/analog/oneshot/cfunc.mod +++ b/src/xspice/icm/analog/oneshot/cfunc.mod @@ -315,13 +315,13 @@ if((PORT_NULL(clear) != 1) && (INPUT(clear) > trig_clk)){ /* Allocate storage for breakpoint domain & freq. range values */ - x = (double *) calloc(cntl_size, sizeof(double)); + x = (double *) calloc((size_t) cntl_size, sizeof(double)); if (!x) { cm_message_send(oneshot_allocation_error); return; } - y = (double *) calloc(pw_size, sizeof(double)); + y = (double *) calloc((size_t) pw_size, sizeof(double)); if (!y) { cm_message_send(oneshot_allocation_error); return; diff --git a/src/xspice/icm/analog/pwl/cfunc.mod b/src/xspice/icm/analog/pwl/cfunc.mod index e7aac089b..70c05a2b9 100644 --- a/src/xspice/icm/analog/pwl/cfunc.mod +++ b/src/xspice/icm/analog/pwl/cfunc.mod @@ -270,13 +270,13 @@ void cm_pwl(ARGS) /* structure holding parms, last_x_value = (double *) STATIC_VAR(last_x_value); /* Allocate storage for breakpoint domain & range values */ - STATIC_VAR(x) = (double *) calloc(size, sizeof(double)); + STATIC_VAR(x) = (double *) calloc((size_t) size, sizeof(double)); x = (double *) STATIC_VAR(x); if (!x) { cm_message_send(allocation_error); } - STATIC_VAR(y) = (double *) calloc(size, sizeof(double)); + STATIC_VAR(y) = (double *) calloc((size_t) size, sizeof(double)); y = (double *) STATIC_VAR(y); if (!y) { cm_message_send(allocation_error); diff --git a/src/xspice/icm/analog/s_xfer/cfunc.mod b/src/xspice/icm/analog/s_xfer/cfunc.mod index 6f7cc97a4..8a128fee7 100644 --- a/src/xspice/icm/analog/s_xfer/cfunc.mod +++ b/src/xspice/icm/analog/s_xfer/cfunc.mod @@ -281,16 +281,16 @@ void cm_s_xfer(ARGS) /* structure holding parms, inputs, outputs, etc. */ /* We have to allocate memory and use cm_analog_alloc, because the ITP variables are not functional */ - integrator = (double **) calloc(den_size, sizeof(double *)); - old_integrator = (double **) calloc(den_size, sizeof(double *)); + integrator = (double **) calloc((size_t) den_size, sizeof(double *)); + old_integrator = (double **) calloc((size_t) den_size, sizeof(double *)); /* Allocate storage for coefficient values */ - den_coefficient = (double **) calloc(den_size,sizeof(double *)); - old_den_coefficient = (double **) calloc(den_size,sizeof(double *)); + den_coefficient = (double **) calloc((size_t) den_size, sizeof(double *)); + old_den_coefficient = (double **) calloc((size_t) den_size, sizeof(double *)); - num_coefficient = (double **) calloc(num_size,sizeof(double *)); - old_num_coefficient = (double **) calloc(num_size,sizeof(double *)); + num_coefficient = (double **) calloc((size_t) num_size, sizeof(double *)); + old_num_coefficient = (double **) calloc((size_t) num_size, sizeof(double *)); for (i=0; i < (2*den_size + num_size + 3); i++) cm_analog_alloc(i,sizeof(double)); @@ -327,8 +327,8 @@ void cm_s_xfer(ARGS) /* structure holding parms, inputs, outputs, etc. */ /* Set pointers to storage locations for in, out, and integrators...*/ - integrator = (double **) calloc(den_size,sizeof(double *)); - old_integrator = (double **) calloc(den_size,sizeof(double *)); + integrator = (double **) calloc((size_t) den_size, sizeof(double *)); + old_integrator = (double **) calloc((size_t) den_size, sizeof(double *)); for (i=0; istate = (int *) calloc(states->depth + 1,sizeof(int)); - states->bits = (short *) calloc((states->num_outputs * states->depth / 4 + 1),sizeof(short)); - states->inputs = (short *) calloc((states->num_inputs * states->depth / 8 + 1),sizeof(short)); - states->next_state = (int *) calloc(states->depth + 1,sizeof(int)); + states->state = (int *) calloc((size_t) (states->depth + 1), sizeof(int)); + states->bits = (short *) calloc((size_t) (states->num_outputs * states->depth / 4 + 1), sizeof(short)); + states->inputs = (short *) calloc((size_t) (states->num_inputs * states->depth / 8 + 1), sizeof(short)); + states->next_state = (int *) calloc((size_t) (states->depth + 1), sizeof(int)); /* Initialize *state, *bits, *inputs & *next_state to zero */ diff --git a/src/xspice/icm/spice2poly/icm_spice2poly/cfunc.mod b/src/xspice/icm/spice2poly/icm_spice2poly/cfunc.mod index c0bda45af..7a23bf3a6 100644 --- a/src/xspice/icm/spice2poly/icm_spice2poly/cfunc.mod +++ b/src/xspice/icm/spice2poly/icm_spice2poly/cfunc.mod @@ -99,7 +99,7 @@ void spice2poly (ARGS) /* array */ if(INIT) { - acgains = (double *) malloc(num_inputs * sizeof(double)); + acgains = (double *) malloc((size_t) num_inputs * sizeof(double)); for(i = 0; i < num_inputs; i++) acgains[i] = 0.0; STATIC_VAR(acgains) = acgains; @@ -121,19 +121,19 @@ void spice2poly (ARGS) /* Get input values and coefficients to local storage for faster access */ - in = (double *) malloc(num_inputs * sizeof(double)); + in = (double *) malloc((size_t) num_inputs * sizeof(double)); for(i = 0; i < num_inputs; i++) in[i] = INPUT(in[i]); num_coefs = PARAM_SIZE(coef); - coef = (double *) malloc(num_coefs * sizeof(double)); + coef = (double *) malloc((size_t) num_coefs * sizeof(double)); for(i = 0; i < num_coefs; i++) coef[i] = PARAM(coef[i]); /* Allocate the array of exponents used in computing the poly terms */ - exp = (int *) malloc(num_inputs * sizeof(int)); + exp = (int *) malloc((size_t) num_inputs * sizeof(int)); /* Initialize the exponents to zeros */ for(i = 0; i < num_inputs; i++) diff --git a/src/xspice/icm/xtradev/core/cfunc.mod b/src/xspice/icm/xtradev/core/cfunc.mod index 3abdf7900..badd3284b 100644 --- a/src/xspice/icm/xtradev/core/cfunc.mod +++ b/src/xspice/icm/xtradev/core/cfunc.mod @@ -273,12 +273,12 @@ void cm_core(ARGS) /* structure holding parms, size = PARAM_SIZE(H_array); /* Allocate storage for breakpoint domain & range values */ - H = (double *) calloc(size, sizeof(double)); + H = (double *) calloc((size_t) size, sizeof(double)); if (!H) { cm_message_send(allocation_error); return; } - B = (double *) calloc(size, sizeof(double)); + B = (double *) calloc((size_t) size, sizeof(double)); if (!B) { cm_message_send(allocation_error); return; diff --git a/src/xspice/ipc/ipc.c b/src/xspice/ipc/ipc.c index 7c35113a6..a432f8ee2 100755 --- a/src/xspice/ipc/ipc.c +++ b/src/xspice/ipc/ipc.c @@ -473,7 +473,7 @@ ipc_send_line_binary ( /* * finally, concatenate the str to the end of the buffer and add the newline: */ - memcpy (&out_buffer[fill_count], str, len); + memcpy (&out_buffer[fill_count], str, (size_t) len); fill_count += len; out_buffer[fill_count] = '\n';