changeset 452:d1f7ddc84c7c

Return more sensible error values where appropriate instead of just DMERR_INVALID_DATA.
author Matti Hamalainen <ccr@tnsp.org>
date Sun, 04 Nov 2012 12:07:03 +0200
parents fdc91f2a0d27
children 349a2ff11531
files libgfx.c
diffstat 1 files changed, 6 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/libgfx.c	Sun Nov 04 12:06:26 2012 +0200
+++ b/libgfx.c	Sun Nov 04 12:07:03 2012 +0200
@@ -387,7 +387,8 @@
         case DM_IFMT_RGB    : fmt = PNG_COLOR_TYPE_RGB; break;
         case DM_IFMT_RGBA   : fmt = PNG_COLOR_TYPE_RGB_ALPHA; break;
         default:
-            dmError("PNG: Internal error, unsupported image format %d.\n", spec->format);
+            dmError("PNG: Unsupported image format %d.\n", spec->format);
+            res = DMERR_NOT_SUPPORTED;
             goto error;
     }
  
@@ -409,6 +410,7 @@
         if (palette == NULL)
         {
             dmError("PNG: Could not allocate palette structure.");
+            res = DMERR_MALLOC;
             goto error;
         }
         
@@ -1272,7 +1274,7 @@
                     iff.bmhd.masking != IFF_MASK_TRANSP))
                 {
                     dmError("ILBM: Unsupported features, refusing to load.\n");
-                    return DMERR_INVALID_DATA;
+                    return DMERR_NOT_SUPPORTED;
                 }
 
                 if (!dmSkipIFFChunkRest(fp, &chunk, sizeof(iff.bmhd)))
@@ -1353,7 +1355,7 @@
                 if ((iff.camg & IFF_CAMG_HAM))
                 {
                     dmError("ILBM: HAM files are not supported.\n");
-                    return DMERR_INVALID_DATA;
+                    return DMERR_NOT_SUPPORTED;
                 }
 
                 if (!dmSkipIFFChunkRest(fp, &chunk, 4))
@@ -1388,7 +1390,7 @@
             if (iff.ncolors > 128)
             {
                 dmError("ILBM: Halfbrite enabled, but ncolors > 128.\n");
-                return DMERR_INVALID_DATA;
+                return DMERR_NOT_SUPPORTED;
             }
 
             if ((iff.pal = dmRealloc(iff.pal, sizeof(DMColor) * iff.ncolors * 2)) == NULL)