add casts to make `int' versus `size_t' conversions explicit

This commit is contained in:
rlar 2010-11-02 17:07:57 +00:00
parent a0235ee242
commit 01566f2b49
41 changed files with 134 additions and 93 deletions

View File

@ -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

View File

@ -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);
}

View File

@ -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]);

View File

@ -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);
}
}
}

View File

@ -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++) {

View File

@ -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",

View File

@ -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) ||

View File

@ -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 ??? */

View File

@ -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) {

View File

@ -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("=");

View File

@ -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);

View File

@ -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++;

View File

@ -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]);

View File

@ -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;

View File

@ -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;
}

View File

@ -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))

View File

@ -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);

View File

@ -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

View File

@ -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;

View File

@ -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)){

View File

@ -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:;

View File

@ -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) {

View File

@ -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! */

View File

@ -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=" */

View File

@ -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;

View File

@ -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++) {

View File

@ -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;

View File

@ -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");

View File

@ -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 */

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -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; i<den_size; i++) {
integrator[i] = (double *) cm_analog_get_ptr(i,0);
@ -342,8 +342,8 @@ void cm_s_xfer(ARGS) /* structure holding parms, inputs, outputs, etc. */
/* Set den_coefficient & gain pointers to ITP values */
/* for denominator coefficients & gain... */
old_den_coefficient = (double **) calloc(den_size,sizeof(double));
den_coefficient = (double **) calloc(den_size,sizeof(double));
old_den_coefficient = (double **) calloc((size_t) den_size, sizeof(double));
den_coefficient = (double **) calloc((size_t) den_size, sizeof(double));
for(i=den_size;i<2*den_size;i++){
old_den_coefficient[i-den_size] = (double *) cm_analog_get_ptr(i,1);
@ -351,8 +351,8 @@ void cm_s_xfer(ARGS) /* structure holding parms, inputs, outputs, etc. */
*(den_coefficient[i-den_size]) = *(old_den_coefficient[i-den_size]);
}
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=2*den_size;i<2*den_size+num_size;i++){
old_num_coefficient[i-2*den_size] = (double *) cm_analog_get_ptr(i,1);

View File

@ -178,12 +178,12 @@ void cm_sine(ARGS) /* structure holding parms,
phase1 = (double *) cm_analog_get_ptr(INT1,1);
/* 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(allocation_error);
return;
}
y = (double *) calloc(freq_size, sizeof(double));
y = (double *) calloc((size_t) freq_size, sizeof(double));
if (!y) {
cm_message_send(allocation_error);
return;

View File

@ -244,13 +244,13 @@ void cm_square(ARGS) /* structure holding parms,
/* 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(square_allocation_error);
return;
}
y = (double *) calloc(freq_size, sizeof(double));
y = (double *) calloc((size_t) freq_size, sizeof(double));
if (!y) {
cm_message_send(square_allocation_error);
return;

View File

@ -233,13 +233,13 @@ void cm_triangle(ARGS) /* structure holding parms,
/* 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(triangle_allocation_error);
return;
}
y = (double *) calloc(freq_size, sizeof(double));
y = (double *) calloc((size_t) freq_size, sizeof(double));
if (!y) {
cm_message_send(triangle_allocation_error);
return;

View File

@ -279,13 +279,13 @@ void cm_d_osc(ARGS)
/* 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(d_osc_allocation_error);
return;
}
y = (double *) calloc(freq_size, sizeof(double));
y = (double *) calloc((size_t) freq_size, sizeof(double));
if (!y) {
cm_message_send(d_osc_allocation_error);
return;

View File

@ -1947,10 +1947,10 @@ void cm_d_state(ARGS)
/* assign storage for arrays to pointers in states table */
states->state = (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 */

View File

@ -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++)

View File

@ -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;

View File

@ -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';