[GRASS-SVN] r62412 - in grass/trunk: imagery/i.atcorr raster/r.contour raster/r.sunmask raster/simwe/r.sim.sediment
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Oct 27 01:19:45 PDT 2014
Author: neteler
Date: 2014-10-27 01:19:45 -0700 (Mon, 27 Oct 2014)
New Revision: 62412
Modified:
grass/trunk/imagery/i.atcorr/aerosolmodel.cpp
grass/trunk/raster/r.contour/cont.c
grass/trunk/raster/r.sunmask/main.c
grass/trunk/raster/simwe/r.sim.sediment/main.c
Log:
Fixes for Coverity Scan: UNINTENDED_INTEGER_DIVISION (proposed by Glynn)
Modified: grass/trunk/imagery/i.atcorr/aerosolmodel.cpp
===================================================================
--- grass/trunk/imagery/i.atcorr/aerosolmodel.cpp 2014-10-27 03:51:38 UTC (rev 62411)
+++ grass/trunk/imagery/i.atcorr/aerosolmodel.cpp 2014-10-27 08:19:45 UTC (rev 62412)
@@ -385,7 +385,7 @@
for(int k = 1; k <= mu; k++)
{
- double co_n = (2 * k + 1) / k / (k + 1);
+ double co_n = (2.0 * k + 1) / k / (k + 1);
RS1 += co_n * (RAn[k] * PIn[k] + RBn[k] * TAUn[k]);
RS2 += co_n * (RAn[k] * TAUn[k] + RBn[k] * PIn[k]);
IS1 += co_n * (IAn[k] * PIn[k] + IBn[k] * TAUn[k]);
Modified: grass/trunk/raster/r.contour/cont.c
===================================================================
--- grass/trunk/raster/r.contour/cont.c 2014-10-27 03:51:38 UTC (rev 62411)
+++ grass/trunk/raster/r.contour/cont.c 2014-10-27 08:19:45 UTC (rev 62412)
@@ -346,9 +346,9 @@
if (Rast_raster_cmp(&curr->z[p1], &curr->z[p2], DCELL_TYPE) == 0)
ratio = 1;
else if (Rast_is_d_null_value(&curr->z[p1]))
- ratio = 1 / 2;
+ ratio = 0.5;
else if (Rast_is_d_null_value(&curr->z[p2]))
- ratio = 1 / 2;
+ ratio = 0.5;
else
ratio = (level - curr->z[p1]) / (curr->z[p2] - curr->z[p1]);
Modified: grass/trunk/raster/r.sunmask/main.c
===================================================================
--- grass/trunk/raster/r.sunmask/main.c 2014-10-27 03:51:38 UTC (rev 62411)
+++ grass/trunk/raster/r.sunmask/main.c 2014-10-27 08:19:45 UTC (rev 62412)
@@ -361,7 +361,7 @@
fprintf(stdout, "sunangleabovehorizon=%f\n",
pdat->elevref);
- if (sretr / 60 <= 24.0) {
+ if (sretr / 60 <= 24) {
fprintf(stdout, "sunrise=%02d:%02d:%02d\n",
sretr / 60, sretr % 60, sretr_sec);
fprintf(stdout, "sunset=%02d:%02d:%02d\n", ssetr / 60,
@@ -382,7 +382,7 @@
fprintf(stdout, "Solar position: sun azimuth: %f, sun angle above horz. (refraction corrected): %f\n",
pdat->azim, pdat->elevref);
- if (sretr / 60 <= 24.0) {
+ if (sretr / 60 <= 24) {
fprintf(stdout, "Sunrise time (without refraction): %02d:%02d:%02d\n",
sretr / 60, sretr % 60, sretr_sec);
fprintf(stdout, "Sunset time (without refraction): %02d:%02d:%02d\n",
@@ -409,7 +409,7 @@
if (use_solpos) {
G_debug(3, "current_time:%f sunrise:%f", current_time, sunrise);
if ((current_time < sunrise)) {
- if (sretr / 60 <= 24.0)
+ if (sretr / 60 <= 24)
G_message(_("Time (%02i:%02i:%02i) is before sunrise (%02d:%02d:%02d)"),
pdat->hour, pdat->minute, pdat->second, sretr / 60,
sretr % 60, sretr_sec);
@@ -420,7 +420,7 @@
G_warning(_("Nothing to calculate. Please verify settings."));
}
if ((current_time > sunset)) {
- if (sretr / 60 <= 24.0)
+ if (sretr / 60 <= 24)
G_message(_("Time (%02i:%02i:%02i) is after sunset (%02d:%02d:%02d)"),
pdat->hour, pdat->minute, pdat->second, ssetr / 60,
ssetr % 60, ssetr_sec);
Modified: grass/trunk/raster/simwe/r.sim.sediment/main.c
===================================================================
--- grass/trunk/raster/simwe/r.sim.sediment/main.c 2014-10-27 03:51:38 UTC (rev 62411)
+++ grass/trunk/raster/simwe/r.sim.sediment/main.c 2014-10-27 08:19:45 UTC (rev 62412)
@@ -101,7 +101,6 @@
{
int ii;
int ret_val;
- double x_orig, y_orig;
static int rand1 = 12345;
static int rand2 = 67891;
@@ -274,8 +273,6 @@
step = (stepx + stepy) / 2.;
mx = cellhd.cols;
my = cellhd.rows;
- x_orig = cellhd.west * conv;
- y_orig = cellhd.south * conv; /* do we need this? */
xmin = 0.;
ymin = 0.;
xp0 = xmin + stepx / 2.;
@@ -330,9 +327,9 @@
/* Recompute timesec from user input in minutes
* to real timesec in seconds */
- timesec = timesec * 60.0;
- iterout = iterout * 60.0;
- if ((timesec / iterout) > 100.0)
+ timesec = timesec * 60;
+ iterout = iterout * 60;
+ if ((timesec / iterout) > 100)
G_message(_("More than 100 files are going to be created !!!!!"));
/* compute how big the raster is and set this to appr 2 walkers per cell */
More information about the grass-commit
mailing list