[GRASS-dev] [GRASS-SVN] r72948 - grass/trunk/misc/m.nviz.image
Anna Petrášová
kratochanna at gmail.com
Wed Jul 4 17:15:41 PDT 2018
On Wed, Jul 4, 2018 at 3:11 PM <svn_grass at osgeo.org> wrote:
> 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;
> }
>
>
Shouldn't it be
return GS_write_ppm(name);
the return code of GS_write_ppm is 1 when it fails, so there shouldn't be
the negation?
Anna
> _______________________________________________
> grass-commit mailing list
> grass-commit at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/grass-commit
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-dev/attachments/20180704/949a95d9/attachment.html>
More information about the grass-dev
mailing list