瀏覽代碼

Fixes for Coverity Scan: UNINTENDED_INTEGER_DIVISION (proposed by Glynn)

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@62412 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Neteler 10 年之前
父節點
當前提交
fd3e7f4763
共有 4 個文件被更改,包括 10 次插入13 次删除
  1. 1 1
      imagery/i.atcorr/aerosolmodel.cpp
  2. 2 2
      raster/r.contour/cont.c
  3. 4 4
      raster/r.sunmask/main.c
  4. 3 6
      raster/simwe/r.sim.sediment/main.c

+ 1 - 1
imagery/i.atcorr/aerosolmodel.cpp

@@ -385,7 +385,7 @@ void AerosolModel::exscphase(const double X, const double nr,
 
 	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]);

+ 2 - 2
raster/r.contour/cont.c

@@ -346,9 +346,9 @@ static void getpoint(struct cell *curr, double level,
     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]);
 

+ 4 - 4
raster/r.sunmask/main.c

@@ -361,7 +361,7 @@ int main(int argc, char *argv[])
 		    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 @@ int main(int argc, char *argv[])
 		    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 @@ int main(int argc, char *argv[])
     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 @@ int main(int argc, char *argv[])
 	    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);

+ 3 - 6
raster/simwe/r.sim.sediment/main.c

@@ -101,7 +101,6 @@ int main(int argc, char *argv[])
 {
     int ii;
     int ret_val;
-    double x_orig, y_orig;
     static int rand1 = 12345;
     static int rand2 = 67891;
 
@@ -274,8 +273,6 @@ int main(int argc, char *argv[])
     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 @@ int main(int argc, char *argv[])
 
     /* 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 */