fix pngread error handling
authorkub <derkub@gmail.com>
Mon, 25 Mar 2024 23:56:33 +0000 (00:56 +0100)
committerkub <derkub@gmail.com>
Mon, 25 Mar 2024 23:56:33 +0000 (00:56 +0100)
input.h
readpng.c

diff --git a/input.h b/input.h
index ba6c15f..f2a5785 100644 (file)
--- a/input.h
+++ b/input.h
@@ -36,9 +36,6 @@
 #define PEVB_SSLOT_NEXT 24
 #define PEVB_MENU       23
 #define PEVB_FF         22
-#define PEVB_PICO_PNEXT 21
-#define PEVB_PICO_PPREV 20
-#define PEVB_PICO_SWINP 19
 
 #define PEV_VOL_DOWN    (1 << PEVB_VOL_DOWN)
 #define PEV_VOL_UP      (1 << PEVB_VOL_UP)
@@ -49,9 +46,6 @@
 #define PEV_SSLOT_NEXT  (1 << PEVB_SSLOT_NEXT)
 #define PEV_MENU        (1 << PEVB_MENU)
 #define PEV_FF          (1 << PEVB_FF)
-#define PEV_PICO_PNEXT  (1 << PEVB_PICO_PNEXT)
-#define PEV_PICO_PPREV  (1 << PEVB_PICO_PPREV)
-#define PEV_PICO_SWINP  (1 << PEVB_PICO_SWINP)
 
 #define PEV_MASK 0x7ff80000
 
index 08bf80d..5f36d6a 100644 (file)
--- a/readpng.c
+++ b/readpng.c
@@ -76,7 +76,7 @@ int readpng(void *dest, const char *fname, readpng_what what, int req_w, int req
                        if (png_get_bit_depth(png_ptr, info_ptr) != 8)
                        {
                                lprintf(__FILE__ ": scaled image uses %ibpc, needed 8bpc\n", png_get_bit_depth(png_ptr, info_ptr));
-                               break;
+                               goto done;
                        }
                        width = png_get_image_width(png_ptr, info_ptr);
                        x_scale = width*65536 / req_w;
@@ -112,7 +112,7 @@ int readpng(void *dest, const char *fname, readpng_what what, int req_w, int req
                        if (png_get_bit_depth(png_ptr, info_ptr) != 8)
                        {
                                lprintf(__FILE__ ": bg image uses %ibpc, needed 8bpc\n", png_get_bit_depth(png_ptr, info_ptr));
-                               break;
+                               goto done;
                        }
                        width = png_get_image_width(png_ptr, info_ptr);
                        if (width > req_w) {
@@ -149,12 +149,12 @@ int readpng(void *dest, const char *fname, readpng_what what, int req_w, int req
                        {
                                lprintf(__FILE__ ": unexpected font image size %dx%d, needed %dx%d\n",
                                        (int)png_get_image_width(png_ptr, info_ptr), (int)png_get_image_height(png_ptr, info_ptr), req_w, req_h);
-                               break;
+                               goto done;
                        }
                        if (png_get_bit_depth(png_ptr, info_ptr) != 8)
                        {
                                lprintf(__FILE__ ": font image uses %ibpp, needed 8bpp\n", png_get_bit_depth(png_ptr, info_ptr));
-                               break;
+                               goto done;
                        }
                        for (y = 0; y < 16; y++)
                        {
@@ -182,12 +182,12 @@ int readpng(void *dest, const char *fname, readpng_what what, int req_w, int req
                        {
                                lprintf(__FILE__ ": unexpected selector image size %ix%i, needed %dx%d\n",
                                        (int)png_get_image_width(png_ptr, info_ptr), (int)png_get_image_height(png_ptr, info_ptr), req_w, req_h);
-                               break;
+                               goto done;
                        }
                        if (png_get_bit_depth(png_ptr, info_ptr) != 8)
                        {
                                lprintf(__FILE__ ": selector image uses %ibpp, needed 8bpp\n", png_get_bit_depth(png_ptr, info_ptr));
-                               break;
+                               goto done;
                        }
                        for (y1 = 0; y1 < req_h; y1++)
                        {
@@ -205,7 +205,7 @@ int readpng(void *dest, const char *fname, readpng_what what, int req_w, int req
                        if (png_get_bit_depth(png_ptr, info_ptr) != 8)
                        {
                                lprintf(__FILE__ ": image uses %ibpc, needed 8bpc\n", png_get_bit_depth(png_ptr, info_ptr));
-                               break;
+                               goto done;
                        }
                        width = png_get_image_width(png_ptr, info_ptr);
                        if (width > req_w)