Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion raster/r.basins.fill/read_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ CELL *read_map(const char *name, int nomask, int nrows, int ncols)
void (*get_row)(int, CELL *, int);

/* allocate entire map */
map = (CELL *)G_malloc(nrows * ncols * sizeof(CELL));
map = (CELL *)G_malloc((size_t)nrows * ncols * sizeof(CELL));

/* open the map */
fd = Rast_open_old(name, "");
Expand Down
5 changes: 3 additions & 2 deletions raster/r.distance/report.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,9 @@ void report(struct Parms *parms)
}

if (parms->sort > 0)
lines = (struct ReportLine *)G_malloc(
map1->edges.ncats * map2->edges.ncats * sizeof(struct ReportLine));
lines = (struct ReportLine *)G_malloc((size_t)map1->edges.ncats *
map2->edges.ncats *
sizeof(struct ReportLine));
else
lines = NULL;
nlines = 0;
Expand Down
8 changes: 4 additions & 4 deletions raster/r.in.mat/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -338,16 +338,16 @@ int main(int argc, char *argv[])
/* 0=double 1=float 2=32bit signed int 5=8bit
* unsigned int(text) */
case 0:
G_fseek(fp1, mrows * ncols * sizeof(double), SEEK_CUR);
G_fseek(fp1, (off_t)mrows * ncols * sizeof(double), SEEK_CUR);
break;
case 1:
G_fseek(fp1, mrows * ncols * sizeof(float), SEEK_CUR);
G_fseek(fp1, (off_t)mrows * ncols * sizeof(float), SEEK_CUR);
break;
case 2:
G_fseek(fp1, mrows * ncols * sizeof(int), SEEK_CUR);
G_fseek(fp1, (off_t)mrows * ncols * sizeof(int), SEEK_CUR);
break;
case 5:
G_fseek(fp1, mrows * ncols * sizeof(char), SEEK_CUR);
G_fseek(fp1, (off_t)mrows * ncols * sizeof(char), SEEK_CUR);
break;
default:
G_fatal_error("unusual array");
Expand Down
32 changes: 16 additions & 16 deletions raster/r.in.xyz/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -857,31 +857,31 @@ int main(int argc, char *argv[])

switch (method) {
case METHOD_N: /* n is a straight copy */
Rast_raster_cpy(raster_row,
n_array +
(row * cols * Rast_cell_size(CELL_TYPE)),
cols, CELL_TYPE);
Rast_raster_cpy(
raster_row,
n_array + ((size_t)row * cols * Rast_cell_size(CELL_TYPE)),
cols, CELL_TYPE);
break;

case METHOD_MIN:
Rast_raster_cpy(raster_row,
min_array +
(row * cols * Rast_cell_size(rtype)),
cols, rtype);
Rast_raster_cpy(
raster_row,
min_array + ((size_t)row * cols * Rast_cell_size(rtype)),
cols, rtype);
break;

case METHOD_MAX:
Rast_raster_cpy(raster_row,
max_array +
(row * cols * Rast_cell_size(rtype)),
cols, rtype);
Rast_raster_cpy(
raster_row,
max_array + ((size_t)row * cols * Rast_cell_size(rtype)),
cols, rtype);
break;

case METHOD_SUM:
Rast_raster_cpy(raster_row,
sum_array +
(row * cols * Rast_cell_size(rtype)),
cols, rtype);
Rast_raster_cpy(
raster_row,
sum_array + ((size_t)row * cols * Rast_cell_size(rtype)),
cols, rtype);
break;

case METHOD_RANGE: /* (max-min) */
Expand Down
4 changes: 2 additions & 2 deletions raster/r.regression.multi/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ int main(int argc, char *argv[])

m = &(m_all[0]);
m->n = n_predictors + 1;
m->v = (double *)G_malloc(m->n * m->n * sizeof(double));
m->v = (double *)G_malloc((size_t)m->n * m->n * sizeof(double));

a[0] = (double *)G_malloc(m->n * sizeof(double));
B[0] = (double *)G_malloc(m->n * sizeof(double));
Expand All @@ -261,7 +261,7 @@ int main(int argc, char *argv[])
for (k = 1; k <= n_predictors; k++) {
m = &(m_all[k]);
m->n = n_predictors;
m->v = (double *)G_malloc(m->n * m->n * sizeof(double));
m->v = (double *)G_malloc((size_t)m->n * m->n * sizeof(double));
a[k] = (double *)G_malloc(m->n * sizeof(double));
B[k] = (double *)G_malloc(m->n * sizeof(double));

Expand Down
4 changes: 2 additions & 2 deletions raster/r.resamp.filter/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ static void make_h_weights(void)
{
int col;

h_weights = G_malloc(dst_w.cols * col_scale * sizeof(double));
h_weights = G_malloc((size_t)dst_w.cols * col_scale * sizeof(double));
mapcol0 = G_malloc(dst_w.cols * sizeof(int));
mapcol1 = G_malloc(dst_w.cols * sizeof(int));

Expand Down Expand Up @@ -211,7 +211,7 @@ static void make_v_weights(void)
{
int row;

v_weights = G_malloc(dst_w.rows * row_scale * sizeof(double));
v_weights = G_malloc((size_t)dst_w.rows * row_scale * sizeof(double));
maprow0 = G_malloc(dst_w.rows * sizeof(int));
maprow1 = G_malloc(dst_w.rows * sizeof(int));

Expand Down
4 changes: 2 additions & 2 deletions raster/r.ros/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -712,8 +712,8 @@ int main(int argc, char *argv[])
A = 133 / pow(sigma[fuel[col]], 0.7913);
gammamax = pow(sigma[fuel[col]], 1.5) /
(495 + 0.0594 * pow(sigma[fuel[col]], 1.5));
gamma =
gammamax * pow(beta / betaop, A) * exp(A * (1 - beta / betaop));
gamma = gammamax * pow(beta / betaop, A) *
exp((double)A * (1 - beta / betaop));
xi = exp((0.792 + 0.681 * pow(sigma[fuel[col]], 0.5)) *
(beta + 0.1)) /
(192 + 0.2595 * sigma[fuel[col]]);
Expand Down
2 changes: 1 addition & 1 deletion raster/r.ros/spot_dist.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ int spot_dist(int fuel, float maxros, int speed, float angle, int row0,

/* get I from Byram's equation, I = R*w*h, cited in Rothermel (1991) */
R = maxros / 60.0;
I = R * w[fuel] * 8000;
I = (double)R * w[fuel] * 8000;

/* get h0 (originally z0) and z0 (e0 + h0) from Chase (1984) */
U = 2 * speed / 88.0;
Expand Down
2 changes: 1 addition & 1 deletion raster/r.sunhours/solpos00.c
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ static void sbcf(struct posdata *pdat, struct trigdata *tdat)
localtrig(pdat, tdat);
p = 0.6366198 * pdat->sbwid / pdat->sbrad * pow(tdat->cd, 3);
t1 = tdat->sl * tdat->sd * pdat->ssha * DEG2RAD;
t2 = tdat->cl * tdat->cd * sin(pdat->ssha * DEG2RAD);
t2 = (double)tdat->cl * tdat->cd * sin(pdat->ssha * DEG2RAD);
pdat->sbcf = pdat->sbsky + 1.0 / (1.0 - p * (t1 + t2));
}

Expand Down
6 changes: 3 additions & 3 deletions raster/r.surf.fractal/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ int process(void)

/*------------------------------------------------------------------*/

if (nn * nn * sizeof(double) < 1)
if ((size_t)nn * nn * sizeof(double) < 1)
G_fatal_error(_("Unable to allocate data buffer. "
"Check current region with g.region."));

data[0] = (double *)G_malloc(nn * nn * sizeof(double));
data[1] = (double *)G_malloc(nn * nn * sizeof(double));
data[0] = (double *)G_malloc((size_t)nn * nn * sizeof(double));
data[1] = (double *)G_malloc((size_t)nn * nn * sizeof(double));

/*------------------------------------------------------------------*/
/* Apply spectral synthesis algorithm. */
Expand Down
4 changes: 2 additions & 2 deletions raster/r.surf.fractal/spec_syn.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ int specsyn(double *data[2], /* Array holding complex data to transform. */
double phase, rad, /* polar coordinates of Fourier coeff. */
*temp[2];

temp[0] = (double *)G_malloc(nn * nn * sizeof(double));
temp[1] = (double *)G_malloc(nn * nn * sizeof(double));
temp[0] = (double *)G_malloc((size_t)nn * nn * sizeof(double));
temp[1] = (double *)G_malloc((size_t)nn * nn * sizeof(double));

/* ---------------------------------------------------------------- */
/* --- Create fractal surface --- */
Expand Down
4 changes: 2 additions & 2 deletions raster/r.texture/h_measure.c
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ float f12_icorr(struct matvec *mv)
for (i = 0; i < Ng; i++) {
for (j = 0; j < Ng; j++) {
if (px[i] * py[j] > 0)
hxy1 -= P[i][j] * log2(px[i] * py[j]);
hxy1 -= P[i][j] * log2((double)px[i] * py[j]);
if (P[i][j] > 0)
hxy -= P[i][j] * log2(P[i][j]);
}
Expand Down Expand Up @@ -437,7 +437,7 @@ float f13_icorr(struct matvec *mv)
for (i = 0; i < Ng; i++) {
for (j = 0; j < Ng; j++) {
if (px[i] * py[j] > 0)
hxy2 -= px[i] * py[j] * log2(px[i] * py[j]);
hxy2 -= (double)px[i] * py[j] * log2((double)px[i] * py[j]);
if (P[i][j] > 0)
hxy -= P[i][j] * log2(P[i][j]);
}
Expand Down
3 changes: 2 additions & 1 deletion raster/r.viewshed/eventlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ double calculate_center_gradient(AEvent *e, Viewpoint *vp)
sqdist = (e->row - vp->row) * (e->row - vp->row) +
(e->col - vp->col) * (e->col - vp->col);

gradient = (e->elev[1] - vp->elev) * (e->elev[1] - vp->elev) / sqdist;
gradient =
(double)(e->elev[1] - vp->elev) * (e->elev[1] - vp->elev) / sqdist;
/*maintain sign */
if (e->elev[1] < vp->elev)
gradient = -gradient;
Expand Down
4 changes: 2 additions & 2 deletions raster/r.viewshed/viewshed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ AEvent *allocate_eventlist(GridHeader *hd)

AEvent *eventList;

long long totalsize = hd->ncols * hd->nrows * 3;
long long totalsize = (long long)hd->ncols * hd->nrows * 3;

totalsize *= sizeof(AEvent);
G_debug(1, "total size of eventlist is %lld B (%d MB); ", totalsize,
Expand Down Expand Up @@ -195,7 +195,7 @@ MemoryVisibilityGrid *viewshed_in_memory(char *inputfname, GridHeader *hd,
assert(visgrid);
G_debug(1, "visibility grid size: %d x %d x %d B (%d MB)", hd->nrows,
hd->ncols, (int)sizeof(float),
(int)(((long long)(hd->nrows * hd->ncols * sizeof(float))) >> 20));
(int)(((long long)hd->nrows * hd->ncols * sizeof(float)) >> 20));

/* ------------------------------ */
/* construct the event list corresponding to the given input file
Expand Down
2 changes: 1 addition & 1 deletion raster/r.watershed/ram/flag_create.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ FLAG *flag_create(int nrows, int ncols)
new_flag->array =
(unsigned char **)G_malloc(nrows * sizeof(unsigned char *));

temp = (unsigned char *)G_malloc(nrows * new_flag->leng *
temp = (unsigned char *)G_malloc((size_t)nrows * new_flag->leng *
sizeof(unsigned char));

for (i = 0; i < nrows; i++) {
Expand Down
2 changes: 1 addition & 1 deletion raster/r.watershed/ram/ramseg.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ size_t seg_index_rc(int ramseg, size_t seg_index, int *r, int *c)
seg_no = seg_index >> DOUBLEBITS;
seg_remainder = seg_index - (seg_no << DOUBLEBITS);
*r = ((seg_no / ramseg) << RAMSEGBITS) + (seg_remainder >> RAMSEGBITS);
*c = ((seg_no - ((*r) >> RAMSEGBITS) * ramseg) << RAMSEGBITS) +
*c = ((seg_no - (size_t)((*r) >> RAMSEGBITS) * ramseg) << RAMSEGBITS) +
seg_remainder - (((*r) & SEGLENLESS) << RAMSEGBITS);
return seg_no;
}
Loading