[GRASS-SVN] [GRASS-dev] r72948 - grass/trunk/misc/m.nviz.image
Huidae Cho
grass4u at gmail.com
Wed Jul 4 20:20:39 PDT 2018
Anna,
You're right! Good catch. I switched 0 & 1 for write_img once again. It was
my holiday brain... Sorry about that. Fixed in r72951.
Thanks for catching the mistake.
Huidae
On Wed, Jul 4, 2018 at 8:15 PM, Anna Petrášová <kratochanna at gmail.com>
wrote:
>
>
> 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
>
>
> _______________________________________________
> grass-dev mailing list
> grass-dev at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/grass-dev
>
--
Huidae Cho, Ph.D., PE, M.ASCE, CFM, GISP
Senior Geospatial Engineer, MapAnything
Open Source GIS Developer, GRASS GIS Development Team
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-commit/attachments/20180704/6fecc7e9/attachment.html>
More information about the grass-commit
mailing list