瀏覽代碼

No need to check return value from Rast_open_* - part 2 - libraries

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@40216 15284696-431f-4ddb-bdfa-cd5b030d7da7
Glynn Clements 15 年之前
父節點
當前提交
b85f8de162
共有 4 個文件被更改,包括 18 次插入106 次删除
  1. 1 8
      lib/gpde/N_arrays_io.c
  2. 5 15
      lib/ogsf/Gs3.c
  3. 6 41
      lib/rst/interp_float/output2d.c
  4. 6 42
      lib/rst/interp_float/resout2d.c

+ 1 - 8
lib/gpde/N_arrays_io.c

@@ -53,9 +53,6 @@ N_array_2d *N_read_rast_to_array_2d(char *name, N_array_2d * array)
     struct Cell_head region;
     struct Cell_head region;
     N_array_2d *data = array;
     N_array_2d *data = array;
 
 
-    if (NULL == G_find_raster2(name, ""))
-	G_fatal_error(_("Raster map <%s> not found"), name);
-
     /* Get the active region */
     /* Get the active region */
     G_get_set_window(&region);
     G_get_set_window(&region);
 
 
@@ -64,9 +61,7 @@ N_array_2d *N_read_rast_to_array_2d(char *name, N_array_2d * array)
     cols = region.cols;
     cols = region.cols;
 
 
     /*open the raster map */
     /*open the raster map */
-    map = Rast_open_old(name, G_find_raster2(name, ""));
-    if (map < 0)
-	G_fatal_error(_("Unable to open raster map <%s>"), name);
+    map = Rast_open_old(name, "");
 
 
     type = Rast_get_map_type(map);
     type = Rast_get_map_type(map);
 
 
@@ -200,8 +195,6 @@ void N_write_array_2d_to_rast(N_array_2d * array, char *name)
 
 
     /*Open the new map */
     /*Open the new map */
     map = Rast_open_new(name, type);
     map = Rast_open_new(name, type);
-    if (map < 0)
-	G_fatal_error(_("Unable to create raster map <%s>"), name);
 
 
     if (type == CELL_TYPE)
     if (type == CELL_TYPE)
 	rast = Rast_allocate_buf(type);
 	rast = Rast_allocate_buf(type);

+ 5 - 15
lib/ogsf/Gs3.c

@@ -134,9 +134,7 @@ int Gs_loadmap_as_float(struct Cell_head *wind, const char *map_name,
 	G_fatal_error(_("Unable to allocate memory for a null buffer"));
 	G_fatal_error(_("Unable to allocate memory for a null buffer"));
     }
     }
 
 
-    if ((cellfile = Rast_open_old(map_name, map_set)) == -1) {
-	G_fatal_error(_("Unable to open raster map <%s>"), map_name);
-    }
+    cellfile = Rast_open_old(map_name, map_set);
 
 
     G_message(_("Loading raster map <%s>..."),
     G_message(_("Loading raster map <%s>..."),
 	      G_fully_qualified_name(map_name, map_set));
 	      G_fully_qualified_name(map_name, map_set));
@@ -209,9 +207,7 @@ int Gs_loadmap_as_int(struct Cell_head *wind, const char *map_name, int *buff,
 	G_fatal_error(_("Unable to allocate memory for a null buffer"));
 	G_fatal_error(_("Unable to allocate memory for a null buffer"));
     }
     }
 
 
-    if ((cellfile = Rast_open_old(map_name, map_set)) == -1) {
-	G_fatal_error(_("Unable to open raster map <%s>"), map_name);
-    }
+    cellfile = Rast_open_old(map_name, map_set);
 
 
     G_message(_("Loading raster map <%s>..."),
     G_message(_("Loading raster map <%s>..."),
 	      G_fully_qualified_name(map_name, map_set));
 	      G_fully_qualified_name(map_name, map_set));
@@ -367,9 +363,7 @@ int Gs_loadmap_as_short(struct Cell_head *wind, const char *map_name,
 	G_fatal_error(_("Unable to allocate memory for a null buffer"));
 	G_fatal_error(_("Unable to allocate memory for a null buffer"));
     }
     }
 
 
-    if ((cellfile = Rast_open_old(map_name, map_set)) == -1) {
-	G_fatal_error(_("Unable to open raster map <%s>"), map_name);
-    }
+    cellfile = Rast_open_old(map_name, map_set);
 
 
     tmp_buf = (int *)G_malloc(wind->cols * sizeof(int));	/* G_fatal_error */
     tmp_buf = (int *)G_malloc(wind->cols * sizeof(int));	/* G_fatal_error */
     if (!tmp_buf) {
     if (!tmp_buf) {
@@ -483,9 +477,7 @@ int Gs_loadmap_as_char(struct Cell_head *wind, const char *map_name,
 	G_fatal_error(_("Unable to allocate memory for a null buffer"));
 	G_fatal_error(_("Unable to allocate memory for a null buffer"));
     }
     }
 
 
-    if ((cellfile = Rast_open_old(map_name, map_set)) == -1) {
-	G_fatal_error(_("Unable to open raster map <%s>"), map_name);
-    }
+    cellfile = Rast_open_old(map_name, map_set);
 
 
     tmp_buf = (int *)G_malloc(wind->cols * sizeof(int));	/* G_fatal_error */
     tmp_buf = (int *)G_malloc(wind->cols * sizeof(int));	/* G_fatal_error */
     if (!tmp_buf) {
     if (!tmp_buf) {
@@ -574,9 +566,7 @@ int Gs_loadmap_as_bitmap(struct Cell_head *wind, const char *map_name,
 	return -1;
 	return -1;
     }
     }
 
 
-    if ((cellfile = Rast_open_old(map_name, map_set)) == -1) {
-	G_fatal_error(_("Unable to open raster map <%s>"), map_name);
-    }
+    cellfile = Rast_open_old(map_name, map_set);
 
 
     tmp_buf = (int *)G_malloc(wind->cols * sizeof(int));	/* G_fatal_error */
     tmp_buf = (int *)G_malloc(wind->cols * sizeof(int));	/* G_fatal_error */
     if (!tmp_buf) {
     if (!tmp_buf) {

+ 6 - 41
lib/rst/interp_float/output2d.c

@@ -61,58 +61,23 @@ int IL_output_2d(struct interp_params *params, struct Cell_head *cellhd,	/* curr
     /*
     /*
      * G_set_embedded_null_value_mode(1);
      * G_set_embedded_null_value_mode(1);
      */
      */
-    if (params->elev != NULL) {
+    if (params->elev)
 	cf1 = Rast_open_fp_new(params->elev);
 	cf1 = Rast_open_fp_new(params->elev);
-	if (cf1 < 0) {
-	    G_warning(_("Unable to create raster map <%s>"), params->elev);
-	    return -1;
-	}
-    }
 
 
-    if (params->slope != NULL) {
+    if (params->slope)
 	cf2 = Rast_open_fp_new(params->slope);
 	cf2 = Rast_open_fp_new(params->slope);
-	if (cf2 < 0) {
-	    G_warning(_("Unable to create raster map <%s>"),
-		      params->slope);
-	    return -1;
-	}
-    }
 
 
-    if (params->aspect != NULL) {
+    if (params->aspect)
 	cf3 = Rast_open_fp_new(params->aspect);
 	cf3 = Rast_open_fp_new(params->aspect);
-	if (cf3 < 0) {
-	    G_warning(_("Unable to create raster map <%s>"),
-		    params->aspect);
-	    return -1;
-	}
-    }
 
 
-    if (params->pcurv != NULL) {
+    if (params->pcurv)
 	cf4 = Rast_open_fp_new(params->pcurv);
 	cf4 = Rast_open_fp_new(params->pcurv);
-	if (cf4 < 0) {
-	    G_warning(_("Unable to create raster map <%s>"),
-		      params->pcurv);
-	    return -1;
-	}
-    }
 
 
-    if (params->tcurv != NULL) {
+    if (params->tcurv)
 	cf5 = Rast_open_fp_new(params->tcurv);
 	cf5 = Rast_open_fp_new(params->tcurv);
-	if (cf5 < 0) {
-	    G_warning(_("Unable to create raster map <%s>"),
-		      params->tcurv);
-	    return -1;
-	}
-    }
 
 
-    if (params->mcurv != NULL) {
+    if (params->mcurv)
 	cf6 = Rast_open_fp_new(params->mcurv);
 	cf6 = Rast_open_fp_new(params->mcurv);
-	if (cf6 < 0) {
-	    G_warning(_("Unable to create raster map <%s>"),
-		      params->mcurv);
-	    return -1;
-	}
-    }
 
 
     nrows = cellhd->rows;
     nrows = cellhd->rows;
     if (nrows != params->nsizr) {
     if (nrows != params->nsizr) {

+ 6 - 42
lib/rst/interp_float/resout2d.c

@@ -66,59 +66,23 @@ int IL_resample_output_2d(struct interp_params *params, double zmin, double zmax
 
 
     cell1 = Rast_allocate_f_buf();
     cell1 = Rast_allocate_f_buf();
 
 
-    if (params->elev != NULL) {
+    if (params->elev)
 	cf1 = Rast_open_fp_new(params->elev);
 	cf1 = Rast_open_fp_new(params->elev);
-	if (cf1 < 0) {
-	    G_warning(_("Unable to create raster map <%s>"),
-		      params->elev);
-	    return -1;
-	}
-    }
 
 
-    if (params->slope != NULL) {
+    if (params->slope)
 	cf2 = Rast_open_fp_new(params->slope);
 	cf2 = Rast_open_fp_new(params->slope);
-	if (cf2 < 0) {
-	    G_warning(_("Unable to create raster map <%s>"),
-		      params->elev);
-	    return -1;
-	}
-    }
 
 
-    if (params->aspect != NULL) {
+    if (params->aspect)
 	cf3 = Rast_open_fp_new(params->aspect);
 	cf3 = Rast_open_fp_new(params->aspect);
-	if (cf3 < 0) {
-	    G_warning(_("Unable to create raster map <%s>"),
-		      params->elev);
-	    return -1;
-	}
-    }
 
 
-    if (params->pcurv != NULL) {
+    if (params->pcurv)
 	cf4 = Rast_open_fp_new(params->pcurv);
 	cf4 = Rast_open_fp_new(params->pcurv);
-	if (cf4 < 0) {
-	    G_warning(_("Unable to create raster map <%s>"),
-		      params->elev);
-	    return -1;
-	}
-    }
 
 
-    if (params->tcurv != NULL) {
+    if (params->tcurv)
 	cf5 = Rast_open_fp_new(params->tcurv);
 	cf5 = Rast_open_fp_new(params->tcurv);
-	if (cf5 < 0) {
-	    G_warning(_("Unable to create raster map <%s>"),
-		      params->elev);
-	    return -1;
-	}
-    }
 
 
-    if (params->mcurv != NULL) {
+    if (params->mcurv)
 	cf6 = Rast_open_fp_new(params->mcurv);
 	cf6 = Rast_open_fp_new(params->mcurv);
-	if (cf6 < 0) {
-	    G_warning(_("Unable to create raster map <%s>"),
-		      params->elev);
-	    return -1;
-	}
-    }
 
 
     nrows = outhd->rows;
     nrows = outhd->rows;
     if (nrows != params->nsizr) {
     if (nrows != params->nsizr) {