Explorar o código

r.spread: backport small fixes (https://trac.osgeo.org/grass/changeset/60915, https://trac.osgeo.org/grass/changeset/60916) based on what Coverity Scan found

git-svn-id: https://svn.osgeo.org/grass/grass/branches/releasebranch_7_0@61270 15284696-431f-4ddb-bdfa-cd5b030d7da7
Anna Petrášová %!s(int64=11) %!d(string=hai) anos
pai
achega
bcb1f67a59
Modificáronse 2 ficheiros con 10 adicións e 10 borrados
  1. 7 10
      raster/r.spread/main.c
  2. 3 0
      raster/r.spread/spread.c

+ 7 - 10
raster/r.spread/main.c

@@ -232,6 +232,7 @@ int main(int argc, char *argv[])
     parm.init_time->key = "init_time";
     parm.init_time->type = TYPE_STRING;
     parm.init_time->key_desc = "int (>= 0)"; /* TODO: move to ->options */
+    parm.init_time->answer = "0";
     parm.init_time->label =
 	_("Initial time for current simulation (0) (min)");
     parm.init_time->description =
@@ -378,17 +379,13 @@ int main(int argc, char *argv[])
 	comp_dens = 0.5;
     }
     /*Check the given initial time and simulation time lag, assign the default if needed */
-    if (parm.init_time->answer) {
-	init_time = atoi(parm.init_time->answer);
-	if (init_time < 0) {
-	    G_warning("Illegal initial time <%s>", parm.init_time->answer);
-	    G_usage();
-	    exit(EXIT_FAILURE);
-	}
-    }
-    else {
-	time_lag = 0;
+    init_time = atoi(parm.init_time->answer);
+    if (init_time < 0) {
+	G_warning("Illegal initial time <%s>", parm.init_time->answer);
+	G_usage();
+	exit(EXIT_FAILURE);
     }
+
     if (parm.time_lag->answer) {
 	time_lag = atoi(parm.time_lag->answer);
 	if (time_lag < 0) {

+ 3 - 0
raster/r.spread/spread.c

@@ -68,6 +68,9 @@ void spread(void)
     struct cell_ptrHa *to_cell, *old_to_cell;
     struct costHa *pres_cell;
 
+    /* initialize using arbitrary value, this value is never used except for debug */
+    min_cost = 0;
+
     ncells = nrows * ncols;
     G_message
 	("Finding spread time - number of cells visited in percentage ...  %3d%%",