explicit casting double -> int etc.

This commit is contained in:
h_vogt 2011-06-11 17:07:38 +00:00
parent dadc4d5834
commit e6c86b4d98
29 changed files with 97 additions and 78 deletions

View File

@ -1,3 +1,11 @@
2011-06-11 Holger Vogt
* onemesh.c misc.c com_compose.c com_fft.c evaluate.c
hpgl.c linear.c misccoms.c options.c points.c rawfile.c
spec.c spiceif.c variable.c complete.c clip.c graf.c
plot5.c plotit.c spbuild.c dctrcurv.c distoan.c
noisean.c nbjttemp.c urcsetup.c ipc.c ipcstdio.c mifgetvalue.c:
remove compiler warnings by explicit casting double -> int etc.
============================ ngspice-23 ==================================
2011-06-04 Holger Vogt
* tests/bin/ngspice.pm: version 23

View File

@ -240,7 +240,7 @@ adjustBaseContact(ONEdevice *pDevice, int indexEB, int indexBC)
/* Initialize the base contact to be the center of the two junctions */
/* This should take care of uniform dopings. */
midPoint = 0.5 * (indexEB + indexBC);
midPoint = (int)(0.5 * (indexEB + indexBC));
newBaseIndex = midPoint;
if (pBaseNode->baseType == P_TYPE) {

View File

@ -24,22 +24,23 @@ double guessNewConc(double conc, double delta)
lambda = 1.0;
fibn = 1.0;
fibp = 1.0;
newConc = 0.0;
for ( ; !acceptable ; ) {
fib = fibp;
fibp = fibn;
fibn += fib;
lambda *= fibp / fibn;
newConc = conc + delta * lambda;
if( newConc > 0.0 ) {
acceptable = TRUE;
}
else {
/* newConc is still negative but fibp and fibn are large */
if ( (fibp > 1e6) || (fibn > 1e6) ) {
acceptable = TRUE;
newConc = conc;
}
}
fib = fibp;
fibp = fibn;
fibn += fib;
lambda *= fibp / fibn;
newConc = conc + delta * lambda;
if( newConc > 0.0 ) {
acceptable = TRUE;
}
else {
/* newConc is still negative but fibp and fibn are large */
if ( (fibp > 1e6) || (fibn > 1e6) ) {
acceptable = TRUE;
newConc = conc;
}
}
}
return( newConc );
}
@ -64,7 +65,7 @@ double lookup(double **dataTable, double x)
int index, numPoints;
BOOLEAN done = FALSE;
numPoints = dataTable[ 0 ][ 0 ];
numPoints = (int)dataTable[ 0 ][ 0 ];
for( index = 2; index <= numPoints && (!done); index++ ) {
x1 = dataTable[ 0 ][ index ];
/* check if x1 > x */

View File

@ -338,7 +338,7 @@ com_compose(wordlist *wl)
var, val);
return;
}
log = *td;
log = (int)(*td);
} else if (cieq(var, "dec")) {
decgiven = TRUE;
if ((td = ft_numparse(&val, FALSE)) == NULL) {
@ -347,7 +347,7 @@ com_compose(wordlist *wl)
var, val);
return;
}
dec = *td;
dec = (int)(*td);
} else if (cieq(var, "gauss")) {
gaussgiven = TRUE;
if ((td = ft_numparse(&val, FALSE)) == NULL) {
@ -356,7 +356,7 @@ com_compose(wordlist *wl)
var, val);
return;
}
gauss = *td;
gauss = (int)(*td);
} else if (cieq(var, "random")) {
randmgiven = TRUE;
if ((td = ft_numparse(&val, FALSE)) == NULL) {
@ -365,7 +365,7 @@ com_compose(wordlist *wl)
var, val);
return;
}
randm = *td;
randm = (int)(*td);
} else if (cieq(var, "pool")) {
poolgiven = TRUE;
pool = val;
@ -453,7 +453,7 @@ com_compose(wordlist *wl)
for (i = 0, tt = start; i < lin;
i++, tt += step)
data[i] = tt;
length = lin;
length = (int)lin;
} else if (loggiven || decgiven) {
/* Create a log sweep... */
} else if (randmgiven) {

View File

@ -260,7 +260,7 @@ com_psd(wordlist *wl)
int ngood, mm;
unsigned long fpts, i, j, tlen, jj, smooth, hsmooth;
char *s;
struct dvec *f, *vlist, *lv, *vec;
struct dvec *f, *vlist, *lv = NULL, *vec;
struct pnode *names, *first_name;
float *reald, *imagd;
@ -480,7 +480,7 @@ com_psd(wordlist *wl)
for (i = 0; i<ngood; i++) {
for (j = 0; j < tlen; j++){
reald[j] = tdvec[i][j]*win[j];
reald[j] = (float)(tdvec[i][j]*win[j]);
imagd[j] = 0.;
}
for (j = tlen; j < size; j++){
@ -517,21 +517,21 @@ com_psd(wordlist *wl)
for (jj = 0; jj < hsmooth + j; jj++)
sum += fdvec[i][jj].cx_real;
sum /= (double)(hsmooth + j);
reald[j] = sqrt(sum)/scaling;
reald[j] = (float)(sqrt(sum)/scaling);
}
for (j=hsmooth; j<fpts-hsmooth; j++){
sum = 0.;
for (jj = 0; jj < smooth; jj++)
sum += fdvec[i][j-hsmooth+jj].cx_real;
sum /= (double)smooth;
reald[j] = sqrt(sum)/scaling;
reald[j] = (float)(sqrt(sum)/scaling);
}
for (j=fpts-hsmooth; j<fpts; j++){
sum = 0.;
for (jj = 0; jj < smooth; jj++)
sum += fdvec[i][j-hsmooth+jj].cx_real;
sum /= (double)(fpts - j + hsmooth - 1);
reald[j] = sqrt(sum)/scaling;
reald[j] = (float)(sqrt(sum)/scaling);
}
for (j=0; j<fpts; j++)
fdvec[i][j].cx_real = reald[j];

View File

@ -716,11 +716,11 @@ op_ind(struct pnode *arg1, struct pnode *arg2)
*/
if (isreal(ind)) {
newdim = v->v_numdims - 1;
down = up = ind->v_realdata[0];
down = up = (int)(ind->v_realdata[0]);
} else {
newdim = v->v_numdims;
down = realpart(&ind->v_compdata[0]);
up = imagpart(&ind->v_compdata[0]);
down = (int)(realpart(&ind->v_compdata[0]));
up = (int)(imagpart(&ind->v_compdata[0]));
}
if (up < down) {
i = up;

View File

@ -98,13 +98,13 @@ int GL_Init(void)
dispdev->numlinestyles = NUMELEMS(linestyle);
dispdev->numcolors = 6;
dispdev->width = DELXMAX * scale;
dispdev->height = DELYMAX * scale;
dispdev->width = (int)(DELXMAX * scale);
dispdev->height = (int)(DELYMAX * scale);
screenflag = 0;
dispdev->minx = XOFF * 1.0;
dispdev->miny = YOFF * 1.0;
dispdev->minx = (int)(XOFF * 1.0);
dispdev->miny = (int)(YOFF * 1.0);
return(0);
@ -134,8 +134,8 @@ GRAPH *graph)
}
/* reasonable values, used in gr_ for placement */
graph->fontwidth = fontwidth * scale; /* was 12, p.w.h. */
graph->fontheight = fontheight * scale; /* was 24, p.w.h. */
graph->fontwidth = (int)(fontwidth * scale); /* was 12, p.w.h. */
graph->fontheight = (int)(fontheight * scale); /* was 24, p.w.h. */
graph->absolute.width = dispdev->width;
graph->absolute.height = dispdev->height;
@ -229,10 +229,10 @@ double theta, double delta_theta)
{
int x1, y1, angle;
x1 = x0 + r * cos(theta);
y1 = y0 + r * sin(theta);
x1 = x0 + (int)(r * cos(theta));
y1 = y0 + (int)(r * sin(theta));
angle = RAD_TO_DEG * delta_theta;
angle = (int)(RAD_TO_DEG * delta_theta);
fprintf(plotfile, "PU;PA %d , %d;", jgmult*(x1+xoff+XTADJ), jgmult*(y1+yoff+YTADJ));
fprintf(plotfile, "PD;AA %d , %d, %d;", jgmult*(x0+xoff+XTADJ), jgmult*(y0+yoff+YTADJ), angle);

View File

@ -64,7 +64,7 @@ com_linearize(wordlist *wl)
plot_new(new);
plot_setcur(new->pl_typename);
plot_list = new;
len = (tstop - tstart) / tstep + 1.5;
len = (int)((tstop - tstart) / tstep + 1.5);
newtime = alloc(struct dvec);
newtime->v_name = copy(oldtime->v_name);
newtime->v_type = oldtime->v_type;

View File

@ -142,6 +142,8 @@ com_bug(wordlist *wl)
void
com_bug(wordlist *wl)
{
NG_IGNORE(wl);
fprintf(cp_out, "Send mail to the address ngspice-devel@lists.sourceforge.net\n");
return;
}

View File

@ -296,7 +296,7 @@ cp_usrset(struct variable *var, bool isset)
if ((var->va_type == CP_BOOL) && (isset == FALSE))
raw_prec = -1;
else if (var->va_type == CP_REAL)
raw_prec = var->va_real;
raw_prec = (int)(var->va_real);
else if (var->va_type == CP_NUM)
raw_prec = var->va_num;
else
@ -305,7 +305,7 @@ cp_usrset(struct variable *var, bool isset)
if ((var->va_type == CP_BOOL) && (isset == FALSE))
cp_numdgt = -1;
else if (var->va_type == CP_REAL)
cp_numdgt = var->va_real;
cp_numdgt = (int)(var->va_real);
else if (var->va_type == CP_NUM)
cp_numdgt = var->va_num;
else

View File

@ -462,6 +462,8 @@ cp_ccon(bool on)
# endif
#endif
#else
NG_IGNORE(on);
#endif
return;

View File

@ -186,8 +186,8 @@ clip_to_circle(int *x1, int *y1, int *x2, int *y2, int cx, int cy, int rad)
if (gamma < M_PI / 2)
gamma = M_PI - gamma;
beta = M_PI - alpha - gamma;
*x1 = cx + rad * cos(theta1 + beta);
*y1 = cy + rad * sin(theta1 + beta);
*x1 = (int)(cx + rad * cos(theta1 + beta));
*y1 = (int)(cy + rad * sin(theta1 + beta));
}
if (b > rad) {
tt = (c * c + b * b - a * a) / (2 * b * c);
@ -200,8 +200,8 @@ clip_to_circle(int *x1, int *y1, int *x2, int *y2, int cx, int cy, int rad)
if (gamma < M_PI / 2)
gamma = M_PI - gamma;
beta = M_PI - alpha - gamma;
*x2 = cx + rad * cos(theta2 - beta);
*y2 = cy + rad * sin(theta2 - beta);
*x2 = (int)(cx + rad * cos(theta2 - beta));
*y2 = (int)(cy + rad * sin(theta2 - beta));
}
if (flip) {
i = *x1;

View File

@ -493,8 +493,8 @@ gr_resize(GRAPH *graph)
scalex = oldxratio / graph->aspectratiox;
scaley = oldyratio / graph->aspectratioy;
for (k = graph->keyed; k; k = k->next) {
k->x = (k->x - graph->viewportxoff) * scalex + graph->viewportxoff;
k->y = (k->y - graph->viewportyoff) * scaley + graph->viewportyoff;
k->x = (int)((k->x - graph->viewportxoff) * scalex + graph->viewportxoff);
k->y = (int)((k->y - graph->viewportyoff) * scaley + graph->viewportyoff);
}
/* X also generates an expose after a resize.
@ -519,8 +519,8 @@ gr_resize_internal(GRAPH *graph)
{
if (!graph->grid.xsized)
graph->viewport.width = graph->absolute.width -
1.4 * graph->viewportxoff;
graph->viewport.width = (int)(graph->absolute.width -
1.4 * graph->viewportxoff);
if (!graph->grid.ysized)
graph->viewport.height = graph->absolute.height -
2 * graph->viewportyoff;

View File

@ -141,10 +141,10 @@ Plt5_Arc(int xc, int yc, int radius, double theta, double delta_theta)
if(delta_phi > delta_theta)
delta_phi = delta_theta;
x0 = xc + (radius * cos(theta));
y0 = yc + (radius * sin(theta));
x1 = xc + (radius * cos(theta + delta_phi));
y1 = yc + (radius * sin(theta + delta_phi));
x0 = xc + (int)(radius * cos(theta));
y0 = yc + (int)(radius * sin(theta));
x1 = xc + (int)(radius * cos(theta + delta_phi));
y1 = yc + (int)(radius * sin(theta + delta_phi));
putc('a', plotfile);
putsi(xc);

View File

@ -934,7 +934,7 @@ plotit(wordlist *wl, char *hcopy, char *devname)
!isreal(plot_cur->pl_scale) ||
!ciprefix("tran", plot_cur->pl_typename))) {
newlen = (tstop - tstart) / tstep + 1.5;
newlen = (int)((tstop - tstart) / tstep + 1.5);
newscale = TMALLOC(double, newlen);

View File

@ -60,10 +60,10 @@ ft_findpoint(double pt, double *lims, int maxp, int minp, bool islog)
if (islog) {
tl = mylog10(lims[0]);
th = mylog10(lims[1]);
return (((mylog10(pt) - tl) / (th - tl)) *
return (int)(((mylog10(pt) - tl) / (th - tl)) *
(maxp - minp) + minp);
} else {
return (((pt - lims[0]) / (lims[1] - lims[0])) *
return (int)(((pt - lims[0]) / (lims[1] - lims[0])) *
(maxp - minp) + minp);
}
}

View File

@ -484,7 +484,7 @@ raw_read(char *name)
curpl->pl_dvecs = v;
if (!curpl->pl_scale)
curpl->pl_scale = v;
v->v_flags = flags;
v->v_flags = (short)flags;
v->v_plot = curpl;
v->v_length = npoints;
v->v_numdims = 0;

View File

@ -74,7 +74,7 @@ com_spec(wordlist *wl)
span = ((int)(span*stepf*1.000000000001))/stepf;
if (span > 0) {
startf = (int)(startf/stepf*1.000000000001) * stepf;
fpts = (stopf - startf)/stepf + 1;
fpts = (int)((stopf - startf)/stepf + 1.);
if (stopf > startf + (fpts-1)*stepf) fpts++;
} else {
fprintf(cp_err,"Error: time span limits step freq to %1.1e Hz\n",

View File

@ -458,7 +458,7 @@ if_option(CKTcircuit *ckt, char *name, enum cp_types type, void *value)
if (type == CP_NUM)
pval.iValue = *((int *) value);
else if (type == CP_REAL)
pval.iValue = *((double *) value);
pval.iValue = (int)(*((double *) value));
else
goto badtype;
break;
@ -1111,7 +1111,7 @@ doset(CKTcircuit *ckt, int typecode, GENinstance *dev, GENmodel *mod, IFparm *op
iptr = nval.v.vec.iVec = NEWN(int, n);
for (i = 0; i < n; i++)
*iptr++ = *dptr++;
*iptr++ = (int)(*dptr++);
break;
case IF_REAL:
@ -1128,7 +1128,7 @@ doset(CKTcircuit *ckt, int typecode, GENinstance *dev, GENmodel *mod, IFparm *op
switch (opt->dataType & IF_VARTYPES) {
case IF_FLAG:
case IF_INTEGER:
nval.iValue = *val->v_realdata;
nval.iValue = (int)(*val->v_realdata);
break;
case IF_REAL:

View File

@ -159,7 +159,7 @@ cp_vset(char *varname, enum cp_types type, void *value)
else if (eq(copyvarname, "history") && (type == CP_NUM))
cp_maxhistlength = v->va_num;
else if (eq(copyvarname, "history") && (type == CP_REAL))
cp_maxhistlength = v->va_real;
cp_maxhistlength = (int)(v->va_real);
else if (eq(copyvarname, "noclobber"))
cp_noclobber = TRUE;
else if (eq(varname, "echo")) /*CDHW*/

View File

@ -969,7 +969,7 @@ EnlargeMatrix(MatrixPtr Matrix, int NewSize)
return;
/* Expand the matrix frame. */
NewSize = MAX( NewSize, EXPANSION_FACTOR * OldAllocatedSize );
NewSize = (int)MAX( NewSize, EXPANSION_FACTOR * OldAllocatedSize );
Matrix->AllocatedSize = NewSize;
if (( SP_REALLOC(Matrix->IntToExtColMap, int, NewSize+1)) == NULL)
@ -1059,7 +1059,7 @@ ExpandTranslationArrays(MatrixPtr Matrix, int NewSize)
return;
/* Expand the translation arrays ExtToIntRowMap and ExtToIntColMap. */
NewSize = MAX( NewSize, EXPANSION_FACTOR * OldAllocatedSize );
NewSize = (int)MAX( NewSize, EXPANSION_FACTOR * OldAllocatedSize );
Matrix->AllocatedExtSize = NewSize;
if (( SP_REALLOC(Matrix->ExtToIntRowMap, int, NewSize+1)) == NULL)

View File

@ -516,7 +516,7 @@ nextstep:;
#ifdef HAS_WINDOWS
if (i == cv->TRCVnestLevel) {
actval += cv->TRCVvStep[cv->TRCVnestLevel];
SetAnalyse( "dc", (int)abs(((actval * 1000.) / actdiff)));
SetAnalyse( "dc", abs((int)(actval * 1000. / actdiff)));
}
#endif
}

View File

@ -71,14 +71,14 @@ time1 = SPfrontEnd->IFseconds();
exp(log(10.0)/job->DnumSteps);
freqTol = job->DfreqDelta *
job->DstopF1 * ckt->CKTreltol;
NoOfPoints = 1 + floor ((job->DnumSteps) / log(10.0) * log((job->DstopF1+freqTol)/(job->DstartF1)));
NoOfPoints = 1 + (int)floor ((job->DnumSteps) / log(10.0) * log((job->DstopF1+freqTol)/(job->DstartF1)));
break;
case OCTAVE:
job->DfreqDelta =
exp(log(2.0)/job->DnumSteps);
freqTol = job->DfreqDelta *
job->DstopF1 * ckt->CKTreltol;
NoOfPoints = 1 + floor ((job->DnumSteps) / log(2.0) * log((job->DstopF1+freqTol)/(job->DstartF1)));
NoOfPoints = 1 + (int)floor ((job->DnumSteps) / log(2.0) * log((job->DstopF1+freqTol)/(job->DstartF1)));
break;
case LINEAR:
job->DfreqDelta =
@ -86,7 +86,7 @@ time1 = SPfrontEnd->IFseconds();
job->DstartF1)/
(job->DnumSteps+1);
freqTol = job->DfreqDelta * ckt->CKTreltol;
NoOfPoints = job->DnumSteps+1+ floor(freqTol/(job->DfreqDelta));
NoOfPoints = job->DnumSteps+1+ (int)floor(freqTol/(job->DfreqDelta));
break;
default:
return(E_BADPARM);

View File

@ -144,7 +144,7 @@ NOISEan (CKTcircuit *ckt, int restart)
}
} else { /* we must have paused before. pick up where we left off */
step = job->NsavFstp;
step = (int)(job->NsavFstp);
switch (job->NstpType) {
case DECADE:

View File

@ -117,7 +117,7 @@ NBJTtemp(GENmodel *inModel, CKTcircuit *ckt)
printf("Warning: base contact not on node -- adjusting contact\n");
}
NBJTjunctions(pDevice, &indexBE, &indexBC);
pDevice->baseIndex = 0.5 * (indexBE + indexBC);
pDevice->baseIndex = (int)(0.5 * (indexBE + indexBC));
}
if (inst->NBJTtype == PNP) {
pDevice->elemArray[pDevice->baseIndex]->pNodes[0]->baseType = N_TYPE;

View File

@ -83,7 +83,7 @@ URCsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *state)
i0 = here->URClength * model->URCisPerL;
if(!here->URClumpsGiven) {
wnorm = model->URCfmax * r0 * c0 * 2.0 * M_PI;
here->URClumps=MAX(3.0,log(wnorm*(((p-1)/p)*((p-1)/p)))/log(p));
here->URClumps=(int)MAX(3.0,log(wnorm*(((p-1)/p)*((p-1)/p)))/log(p));
if(wnorm <35) here->URClumps=3;
/* may want to limit lumps to <= 100 or something like that */
}

View File

@ -809,9 +809,9 @@ stuff_binary_v1 (
assert (sizeof(char) == 1);
assert ((n >= 1) && (n <= 2));
trick.float_val[0] = d1;
trick.float_val[0] = (float)d1;
if (n > 1) {
trick.float_val[1] = d2;
trick.float_val[1] = (float)d2;
}
for (i = 0, j = pos; i < n*sizeof(float); j++, i++)
buf[j] = trick.ch[i];
@ -936,7 +936,7 @@ ipc_send_event (
/* Put the analysis step bytes in */
buff_len = (int) strlen(buff);
buff_ptr = buff + buff_len;
fvalue = step;
fvalue = (float)step;
temp_ptr = (char *) &fvalue;
for(i = 0; i < 4; i++) {
*buff_ptr = temp_ptr[i];
@ -945,7 +945,7 @@ ipc_send_event (
}
/* Put the plot value in */
fvalue = plot_val;
fvalue = (float)plot_val;
temp_ptr = (char *) &fvalue;
for(i = 0; i < 4; i++) {
*buff_ptr = temp_ptr[i];

View File

@ -27,6 +27,10 @@ Ipc_Status_t ipc_transport_initialize_server (
Ipc_Protocol_t p,
char *batch_filename )
{
NG_IGNORE(server_name);
NG_IGNORE(p);
NG_IGNORE(batch_filename);
assert (m == IPC_MODE_INTERACTIVE);
printf ("INITIALIZE_SERVER\n");
return IPC_STATUS_OK;
@ -38,6 +42,8 @@ Ipc_Status_t ipc_transport_get_line (
int *len,
Ipc_Wait_t wait )
{
NG_IGNORE(wait);
printf ("GET_LINE\n");
gets (str);
*len = strlen (str);

View File

@ -268,9 +268,9 @@ static int MIFget_integer(char *token, char **err)
l = 0;
}
else if(dtemp > 0.0)
l = dtemp + 0.5;
l = (long)(dtemp + 0.5);
else
l = dtemp - 0.5;
l = (long)(dtemp - 0.5);
}
return((int) l);