diff --git a/ChangeLog b/ChangeLog index 7eaa85e87..a3d493114 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,7 +3,8 @@ 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: + noisean.c nbjttemp.c urcsetup.c ipc.c ipcstdio.c mifgetvalue.c + postsc.c grid.c hash.c cktsens.c: remove compiler warnings by explicit casting double -> int etc. ============================ ngspice-23 ================================== diff --git a/src/frontend/plotting/grid.c b/src/frontend/plotting/grid.c index 9668fb462..60912051f 100644 --- a/src/frontend/plotting/grid.c +++ b/src/frontend/plotting/grid.c @@ -253,7 +253,7 @@ lingrid(GRAPH *graph, double lo, double hi, double delta, int type, Axis axis) delta = -delta; } - mag2 = floor(log10(fabs(hi - lo))); + mag2 = (int)floor(log10(fabs(hi - lo))); tenpowmag2 = pow(10.0, (double) mag2); /* Round lo down, and hi up */ @@ -269,9 +269,9 @@ lingrid(GRAPH *graph, double lo, double hi, double delta, int type, Axis axis) hi = hmt * tenpowmag2; if (fabs(hi) > fabs(lo)) - mag = floor(log10(fabs(hi))); + mag = (int)floor(log10(fabs(hi))); else - mag = floor(log10(fabs(lo))); + mag = (int)floor(log10(fabs(lo))); if (mag >= 0) mag3 = ((int) (mag / 3)) * 3; @@ -380,7 +380,7 @@ lingrid(GRAPH *graph, double lo, double hi, double delta, int type, Axis axis) do { step = div_list[i].step; - nsp = (dst + step - 0.0001) / step; + nsp = (int)((dst + step - 0.0001) / step); spacing = (max - margin) / nsp; i += 1; } while ((size_t) i < NUMELEMS(div_list) && spacing > 50); @@ -394,7 +394,7 @@ lingrid(GRAPH *graph, double lo, double hi, double delta, int type, Axis axis) while (i > 0 && spacing < slim + 3) { i -= 1; step = div_list[i].step; - nsp = (dst + step - 0.0001) / step; + nsp = (int)((dst + step - 0.0001) / step); spacing = (max - margin) / nsp; } @@ -413,14 +413,14 @@ lingrid(GRAPH *graph, double lo, double hi, double delta, int type, Axis axis) lo = lmt * tenpowmag2; hi = hmt * tenpowmag2; - nsp = (dst + step - 0.0001) / step; + nsp = (int)((dst + step - 0.0001) / step); } else { /* The user told us where to put the grid lines. They will * not be equally spaced in this case (i.e, the right edge * won't be a line). */ - nsp = (hi - lo) / delta; + nsp = (int)((hi - lo) / delta); if (nsp > 100) nsp = 100; step = (max - margin) * delta / (hi - lo); @@ -433,9 +433,9 @@ lingrid(GRAPH *graph, double lo, double hi, double delta, int type, Axis axis) /* Reset the max coordinate to deal with round-off error. */ if (nsp && (delta == 0.0)) { if (axis == x_axis) - graph->viewport.width = spacing * nsp; + graph->viewport.width = (int)(spacing * nsp); else - graph->viewport.height = spacing * nsp; + graph->viewport.height = (int)(spacing * nsp); } else if (!nsp) { nsp = 1; } @@ -454,7 +454,7 @@ lingrid(GRAPH *graph, double lo, double hi, double delta, int type, Axis axis) graph->grid.xaxis.lin.distance = dst; graph->grid.xaxis.lin.lowlimit = lmt; graph->grid.xaxis.lin.highlimit = hmt; - graph->grid.xaxis.lin.spacing = spacing; + graph->grid.xaxis.lin.spacing = (int)spacing; graph->grid.xaxis.lin.numspace = nsp; } else { graph->grid.ysized = 1; @@ -467,7 +467,7 @@ lingrid(GRAPH *graph, double lo, double hi, double delta, int type, Axis axis) graph->grid.yaxis.lin.distance = dst; graph->grid.yaxis.lin.lowlimit = lmt; graph->grid.yaxis.lin.highlimit = hmt; - graph->grid.yaxis.lin.spacing = spacing; + graph->grid.yaxis.lin.spacing = (int)spacing; graph->grid.yaxis.lin.numspace = nsp; } @@ -494,7 +494,7 @@ drawlingrid(GRAPH *graph, char *units, int spacing, int nsp, double dst, double for (i = 0, m = lmt * 100.0; m - 0.001 <= hmt * 100.0; i += spacing, m += step) { - j = m; + j = (int)m; if (j == 0) SetLinestyle(0); if (graph->grid.gridtype != GRID_NONE) { @@ -576,16 +576,16 @@ loggrid(GRAPH *graph, double lo, double hi, int type, Axis axis) * and lo are positive. */ - lmt = floor(mylog10(lo)); - hmt = ceil(mylog10(hi)); + lmt = (int)floor(mylog10(lo)); + hmt = (int)ceil(mylog10(hi)); decs = hmt - lmt; pp = 1; - decsp = (max - margin) / decs; + decsp = (int)((max - margin) / decs); if (decsp < 20) { - pp = ceil(20.0 / decsp); + pp = (int)ceil(20.0 / decsp); decsp *= pp; subs = 1; } else if (decsp > 50) { @@ -605,9 +605,9 @@ loggrid(GRAPH *graph, double lo, double hi, int type, Axis axis) subs = 1; /* Start at a line */ - lmt = floor((double) lmt / pp) * pp; + lmt = (int)(floor((double) lmt / pp) * pp); decs = hmt - lmt; - decsp = (max - margin) / decs; + decsp = (int)((max - margin) / decs); dd[0] = pow(10.0, (double) lmt); dd[1] = pow(10.0, (double) hmt); @@ -620,7 +620,7 @@ loggrid(GRAPH *graph, double lo, double hi, int type, Axis axis) if (axis == x_axis) { (void) strcpy(graph->grid.xaxis.log.units, buf); - graph->viewport.width = decs * decsp; + graph->viewport.width = (int)(decs * decsp); graph->grid.xaxis.log.hmt = hmt; graph->grid.xaxis.log.lmt = lmt; graph->grid.xaxis.log.decsp = decsp; @@ -629,7 +629,7 @@ loggrid(GRAPH *graph, double lo, double hi, int type, Axis axis) graph->grid.xsized = 1; } else { (void) strcpy(graph->grid.yaxis.log.units, buf); - graph->viewport.height = decs * decsp; + graph->viewport.height = (int)(decs * decsp); graph->grid.yaxis.log.hmt = hmt; graph->grid.yaxis.log.lmt = lmt; graph->grid.yaxis.log.decsp = decsp; @@ -698,8 +698,8 @@ drawloggrid(GRAPH *graph, char *units, int hmt, int lmt, int decsp, int subs, in if (subs > 1) { SetLinestyle(1); t = 10.0 / subs; - for (k = ceil(subs / 10.0) + 1; k < subs; k++) { - m = i + decsp * log10((double) t * k); + for (k = (int)ceil(subs / 10.0) + 1; k < subs; k++) { + m = (int)(i + decsp * log10((double) t * k)); if (graph->grid.gridtype != GRID_NONE) { if (axis == x_axis) DevDrawLine(graph->viewportxoff + m, @@ -775,10 +775,10 @@ polargrid(GRAPH *graph) && (graph->data.xmin == graph->data.ymin)) centered = TRUE; - mag = floor(mylog10(maxrad)); + mag = (int)floor(mylog10(maxrad)); tenpowmag = pow(10.0, (double) mag); - hmt = maxrad / tenpowmag; - lmt = minrad / tenpowmag; + hmt = (int)(maxrad / tenpowmag); + lmt = (int)(minrad / tenpowmag); if (hmt * tenpowmag < maxrad) hmt++; if (lmt * tenpowmag > minrad) @@ -838,15 +838,15 @@ drawpolargrid(GRAPH *graph) pixperunit = graph->grid.xaxis.circular.radius * 2 / (graph->datawindow.xmax - graph->datawindow.xmin); - relcx = - (graph->datawindow.xmin + graph->datawindow.xmax) / 2 - * pixperunit; - relcy = - (graph->datawindow.ymin + graph->datawindow.ymax) / 2 - * pixperunit; + relcx = - (int)((graph->datawindow.xmin + graph->datawindow.xmax) / 2 + * pixperunit); + relcy = - (int)((graph->datawindow.ymin + graph->datawindow.ymax) / 2 + * pixperunit); /* The distance from the center of the plotting area to the center of * the logical area. */ - dist = sqrt((double) (relcx * relcx + relcy * relcy)); + dist = (int)sqrt((double) (relcx * relcx + relcy * relcy)); SetLinestyle(0); DevDrawArc(graph->grid.xaxis.circular.center, @@ -857,7 +857,7 @@ drawpolargrid(GRAPH *graph) /* Now draw the circles. */ for (i = lmt; - (relrad = i * tenpowmag * pixperunit) + (relrad = (int)(i * tenpowmag * pixperunit)) <= dist + graph->grid.xaxis.circular.radius; i += step) { @@ -891,10 +891,10 @@ drawpolargrid(GRAPH *graph) for (i = 0; i < 12; i++) { x1 = graph->grid.xaxis.circular.center + relcx; y1 = graph->grid.yaxis.circular.center + relcy; - x2 = x1 + graph->grid.xaxis.circular.radius * 2 - * cos(i * M_PI / 6); - y2 = y1 + graph->grid.xaxis.circular.radius * 2 - * sin(i * M_PI / 6); + x2 = (int)(x1 + graph->grid.xaxis.circular.radius * 2 + * cos(i * M_PI / 6)); + y2 = (int)(y1 + graph->grid.xaxis.circular.radius * 2 + * sin(i * M_PI / 6)); if (!clip_to_circle(&x1, &y1, &x2, &y2, graph->grid.xaxis.circular.center, graph->grid.yaxis.circular.center, @@ -930,8 +930,8 @@ drawpolargrid(GRAPH *graph) for (i = 0; i < 360; i+= degs) { x1 = graph->grid.xaxis.circular.center + relcx; y1 = graph->grid.yaxis.circular.center + relcy; - x2 = x1 + dist * 2 * cos(i * M_PI / 180); - y2 = y1 + dist * 2 * sin(i * M_PI / 180); + x2 = (int)(x1 + dist * 2 * cos(i * M_PI / 180)); + y2 = (int)(y1 + dist * 2 * sin(i * M_PI / 180)); if (!clip_to_circle(&x1, &y1, &x2, &y2, graph->grid.xaxis.circular.center, graph->grid.yaxis.circular.center, @@ -974,12 +974,12 @@ adddeglabel(GRAPH *graph, int deg, int x, int y, int cx, int cy, int lx, int ly) return; (void) sprintf(buf, "%d", deg); w = graph->fontwidth * (int) (strlen(buf) + 1); - h = graph->fontheight * 1.5; + h = (int)(graph->fontheight * 1.5); angle = atan2((double) (y - ly), (double) (x - lx)); - d = fabs(cos(angle)) * w / 2 + fabs(sin(angle)) * h / 2 + LOFF; + d = (int)(fabs(cos(angle)) * w / 2 + fabs(sin(angle)) * h / 2 + LOFF); - x = x + d * cos(angle) - w / 2; - y = y + d * sin(angle) - h / 2; + x = (int)(x + d * cos(angle) - w / 2); + y = (int)(y + d * sin(angle) - h / 2); DevDrawText(buf, x, y); DevDrawText("o", x + (int) strlen(buf) * graph->fontwidth, @@ -1120,20 +1120,20 @@ drawsmithgrid(GRAPH *graph) maxrad = d + (graph->datawindow.xmax - graph->datawindow.xmin) / 2; minrad = d - (graph->datawindow.xmax - graph->datawindow.xmin) / 2; - mag = floor(mylog10(maxrad)); + mag = (int)floor(mylog10(maxrad)); tenpowmag = pow(10.0, (double) mag); pixperunit = graph->viewport.width / (graph->datawindow.xmax - graph->datawindow.xmin); - xoff = - pixperunit * (graph->datawindow.xmin + graph->datawindow.xmax) / 2; - yoff = - pixperunit * (graph->datawindow.ymin + graph->datawindow.ymax) / 2; + xoff = - (int)(pixperunit * (graph->datawindow.xmin + graph->datawindow.xmax) / 2); + yoff = - (int)(pixperunit * (graph->datawindow.ymin + graph->datawindow.ymax) / 2); /* Sweep the range from 10e-20 to 10e20. If any arcs fall into the * picture, plot the arc set. */ for (mag = -20; mag < 20; mag++) { - i = gr_radius * pow(10.0, (double) mag) / maxrad; + i = (int)(gr_radius * pow(10.0, (double) mag) / maxrad); if (i > 10) { j = 1; break; @@ -1163,7 +1163,7 @@ drawsmithgrid(GRAPH *graph) mag -= 2; j *= 10; while (mag < 20) { - i = j * pow(10.0, (double) mag) * pixperunit / 2; + i = (int)(j * pow(10.0, (double) mag) * pixperunit / 2); if (i / 5 > gr_radius + ((xoff > 0) ? xoff : - xoff)) break; rnorm[k] = j * pow(10.0, (double) (mag - basemag)); @@ -1246,7 +1246,7 @@ drawsmithgrid(GRAPH *graph) kr[i] = ks[j]; if ((yoff > - gr_radius) && (yoff < gr_radius)) { - zheight = gr_radius * cos(asin((double) yoff / gr_radius)); + zheight = (int)(gr_radius * cos(asin((double) yoff / gr_radius))); zheight = (zheight > 0) ? zheight : - zheight; } else { zheight = gr_radius; @@ -1280,7 +1280,7 @@ drawsmithgrid(GRAPH *graph) } */ if ((yoff > - gr_radius) && (yoff < gr_radius)) { - zheight = gr_radius * cos(asin((double) yoff / gr_radius)); + zheight = (int)(gr_radius * cos(asin((double) yoff / gr_radius))); if (zheight < 0) zheight = - zheight; DevDrawLine(gr_xcenter - zheight, gr_ycenter + yoff, @@ -1344,8 +1344,8 @@ arcset(GRAPH *graph, double rad, double prevrad, double irad, double iprevrad, d (double) (M_PI * 1.5 + 2 * iangle), (double) (M_PI * 1.5 - 2 * iangle), centx, centy, maxrad, 1); if ((aclip > M_PI / 180) && (pdeg > 1)) { - xlab = centx + xoffset + radoff + irad * cos(aclip); - ylab = centy + yoffset + irad * (1 + sin(aclip)); + xlab = (int)(centx + xoffset + radoff + irad * cos(aclip)); + ylab = (int)(centy + yoffset + irad * (1 + sin(aclip))); if ((ylab - gr_ycenter) > graph->fontheight) { SetColor(1); adddeglabel(graph, pdeg, xlab, ylab, @@ -1364,8 +1364,8 @@ arcset(GRAPH *graph, double rad, double prevrad, double irad, double iprevrad, d (double) (M_PI / 2 - 2 * iangle), centx, centy, maxrad, (iangle == 0)?2:0); if ((aclip >= 0 && aclip < 2*M_PI - M_PI/180) && (pdeg < 359)) { - xlab = centx + xoffset + radoff + irad * cos(aclip); - ylab = centy + yoffset + irad * (sin(aclip) - 1); + xlab = (int)(centx + xoffset + radoff + irad * cos(aclip)); + ylab = (int)(centy + yoffset + irad * (sin(aclip) - 1)); SetColor(1); adddeglabel(graph, ndeg, xlab, ylab, gr_xcenter, gr_ycenter, gr_xcenter, gr_ycenter); diff --git a/src/frontend/postsc.c b/src/frontend/postsc.c index 29a4833f3..ca4e5f877 100644 --- a/src/frontend/postsc.c +++ b/src/frontend/postsc.c @@ -107,7 +107,7 @@ PS_Init(void) /* plot size */ if (!cp_getvar("hcopywidth", CP_STRING, pswidth)) { - dispdev->width = 7.75 * 72.0 * scale; /* (8 1/2 - 3/4) * 72 */ + dispdev->width = (int)(7.75 * 72.0 * scale); /* (8 1/2 - 3/4) * 72 */ } else { sscanf(pswidth, "%d", &(dispdev->width)); if (dispdev->width <= 100) @@ -141,21 +141,21 @@ PS_Init(void) fontsize = 10; fontwidth = 6; fontheight = 14; - xtadj = XTADJ * scale; - ytadj = YTADJ * scale; + xtadj = (int)(XTADJ * scale); + ytadj = (int)(YTADJ * scale); } else { sscanf(psfontsize, "%d", &fontsize); if ((fontsize < 10) || (fontsize > 14)) fontsize = 10; - fontwidth = 0.5 + 0.6 * fontsize; - fontheight = 2.5 + 1.2 * fontsize; - xtadj = XTADJ * scale * fontsize / 10; - ytadj = YTADJ * scale * fontsize / 10; + fontwidth = (int)(0.5 + 0.6 * fontsize); + fontheight = (int)(2.5 + 1.2 * fontsize); + xtadj = (int)(XTADJ * scale * fontsize / 10); + ytadj = (int)(YTADJ * scale * fontsize / 10); } screenflag = 0; - dispdev->minx = XOFF / scale; - dispdev->miny = YOFF / scale; + dispdev->minx = (int)(XOFF / scale); + dispdev->miny = (int)(YOFF / scale); return(0); @@ -181,8 +181,8 @@ PS_NewViewport(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; @@ -190,13 +190,13 @@ PS_NewViewport(GRAPH *graph) graph->viewportxoff = 8 * fontwidth; graph->viewportyoff = 4 * fontheight; - xoff = scale * XOFF; - yoff = scale * YOFF; + xoff = (int)(scale * XOFF); + yoff = (int)(scale * YOFF); - x1 = 0.75 * 72; + x1 = (int)(0.75 * 72); y1 = x1; - x2 = graph->absolute.width + .75 * 72; - y2 = graph->absolute.height + .75 * 72; + x2 = (int)(graph->absolute.width + .75 * 72); + y2 = (int)(graph->absolute.height + .75 * 72); /* start file off with a % */ fprintf(plotfile, "%%!PS-Adobe-3.0 EPSF-3.0\n"); fprintf(plotfile, "%%%%Creator: nutmeg\n"); diff --git a/src/misc/hash.c b/src/misc/hash.c index 3de2c599e..8b7de5f89 100644 --- a/src/misc/hash.c +++ b/src/misc/hash.c @@ -500,7 +500,7 @@ void * nghash_insert(NGHASHPTR hashtable, void * user_key, void * data) if( hashtable->num_entries >= hashtable->need_resize ){ int newsize ; /* new size of table */ - newsize = hashtable->size * hashtable->growth_factor ; + newsize = (int)(hashtable->size * hashtable->growth_factor); nghash_resize(hashtable, newsize ) ; } diff --git a/src/spicelib/analysis/cktsens.c b/src/spicelib/analysis/cktsens.c index 37cfd830f..246cec24e 100644 --- a/src/spicelib/analysis/cktsens.c +++ b/src/spicelib/analysis/cktsens.c @@ -677,7 +677,7 @@ count_steps(int type, double low, double high, int steps, double *stepsize) low = 1e-3; if (high <= low) high = 10.0 * low; - n = steps * log10(high/low) + 1.01; + n = (int)(steps * log10(high/low) + 1.01); s = pow(10.0, 1.0 / steps); break; @@ -686,7 +686,7 @@ count_steps(int type, double low, double high, int steps, double *stepsize) low = 1e-3; if (high <= low) high = 2.0 * low; - n = steps * log(high/low) / M_LOG2E + 1.01; + n = (int)(steps * log(high/low) / M_LOG2E + 1.01); s = pow(2.0, 1.0 / steps); break; }