[GRASS-SVN] r72948 - grass/trunk/misc/m.nviz.image

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Jul 4 12:11:33 PDT 2018


Author: hcho
Date: 2018-07-04 12:11:33 -0700 (Wed, 04 Jul 2018)
New Revision: 72948

Modified:
   grass/trunk/misc/m.nviz.image/main.c
   grass/trunk/misc/m.nviz.image/write_img.c
Log:
m.nviz.image: Check return value from GS_write_(ppm|tif)

Modified: grass/trunk/misc/m.nviz.image/main.c
===================================================================
--- grass/trunk/misc/m.nviz.image/main.c	2018-07-03 19:44:31 UTC (rev 72947)
+++ grass/trunk/misc/m.nviz.image/main.c	2018-07-04 19:11:33 UTC (rev 72948)
@@ -236,7 +236,9 @@
     if (strcmp(params->format->answer, "tif") == 0)
 	ret = write_img(output_name, FORMAT_TIF);
 
-    if (!ret)
+    if (ret == 1)
+	G_fatal_error(_("Failed to write image"));
+    else if (ret == 2)
 	G_fatal_error(_("Unsupported output format"));
 
     G_done_msg(_("File <%s> created."), output_name);

Modified: grass/trunk/misc/m.nviz.image/write_img.c
===================================================================
--- grass/trunk/misc/m.nviz.image/write_img.c	2018-07-03 19:44:31 UTC (rev 72947)
+++ grass/trunk/misc/m.nviz.image/write_img.c	2018-07-04 19:11:33 UTC (rev 72948)
@@ -23,19 +23,20 @@
 
    \param name filename
 
-   \return 1 on success
-   \return 0 on failure (unsupported format)
+   \return 0 on success
+   \return 1 on failure (failed to write image)
+   \return 2 on failure (unsupported format)
  */
 int write_img(const char *name, int format)
 {
     if (format == FORMAT_PPM)
-	GS_write_ppm(name);
+	return !GS_write_ppm(name);
 #ifdef HAVE_TIFFIO_H
     else if (format == FORMAT_TIF)
-	GS_write_tif(name);
+	return !GS_write_tif(name);
 #endif
     else
-	return 0;
+	return 2;
 
-    return 1;
+    return 0;
 }



More information about the grass-commit mailing list