This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch master
in repository legacy-imlib2.

View the commit online.

commit 8a36ae6d8d4e255dba60b2314663ff5a592b883e
Author: Kim Woelders <k...@woelders.dk>
AuthorDate: Mon May 8 12:27:47 2023 +0200

    loaders: Use common function to print error messages
    
    Also:
    - gif  loader: Add error about corrupt frame sequence
    - tiff loader: Drop OOM message - Not done elsewhere
    - webp loader: Drop messages about quality tag outside [0-100] -
                   Not done elsewhere
---
 src/modules/loaders/loader_gif.c  |  5 ++++-
 src/modules/loaders/loader_id3.c  | 31 +++++++++++++++----------------
 src/modules/loaders/loader_tiff.c |  7 ++-----
 src/modules/loaders/loader_webp.c | 17 +++--------------
 src/modules/loaders/loader_xpm.c  | 12 +++++-------
 5 files changed, 29 insertions(+), 43 deletions(-)

diff --git a/src/modules/loaders/loader_gif.c b/src/modules/loaders/loader_gif.c
index 6939347..97ed54f 100644
--- a/src/modules/loaders/loader_gif.c
+++ b/src/modules/loaders/loader_gif.c
@@ -156,7 +156,10 @@ _load(ImlibImage * im, int load_data)
                   while (data)
                     {
                        if (DGifGetCodeNext(gif, &data) == GIF_ERROR)
-                          goto done;
+                         {
+                            E("Corrupt image frame\n");
+                            goto done;
+                         }
                        DL(" DGifGetCodeNext: size=%d data="" size, data);
                     }
                   continue;
diff --git a/src/modules/loaders/loader_id3.c b/src/modules/loaders/loader_id3.c
index 09ef4ee..4951827 100644
--- a/src/modules/loaders/loader_id3.c
+++ b/src/modules/loaders/loader_id3.c
@@ -5,6 +5,8 @@
 #include <limits.h>
 #include <id3tag.h>
 
+#define DBG_PFX "LDR-id3"
+
 #define USE_TAGS 0
 
 static const char  *const _formats[] = { "mp3" };
@@ -56,14 +58,13 @@ context_create(const char *filename, FILE * f)
       if (!file)
         {
            close(fd);
-           fprintf(stderr, "Unable to open tagged file %s: %s\n",
-                   filename, strerror(errno));
+           E("Unable to open tagged file %s: %m\n", filename);
            goto fail_free;
         }
       tag = id3_file_tag(file);
       if (!tag)
         {
-           fprintf(stderr, "Unable to find ID3v2 tags in file %s\n", filename);
+           E("Unable to find ID3v2 tags in file %s\n", filename);
            id3_file_close(file);
            goto fail_free;
         }
@@ -96,7 +97,7 @@ context_create(const char *filename, FILE * f)
    /* Paranoid! this can occur only if there are INT_MAX contexts :) */
    if (!ptr)
      {
-        fprintf(stderr, "Too many open ID3 contexts\n");
+        E("Too many open ID3 contexts\n");
         goto fail_close;
      }
 
@@ -150,7 +151,7 @@ context_get(int id)
           }
         ptr = ptr->next;
      }
-   fprintf(stderr, "No context by handle %d found\n", id);
+   E("No context by handle %d found\n", id);
    return NULL;
 }
 
@@ -302,7 +303,7 @@ get_options(lopt * opt, const ImlibImage * im)
        (index == 0 && id3_tag_get_numframes(ctx->tag) < 1))
      {
         if (index)
-           fprintf(stderr, "No picture frame # %d found\n", index);
+           E("No picture frame # %d found\n", index);
         context_delref(ctx);
         return 0;
      }
@@ -328,7 +329,7 @@ extract_pic(struct id3_frame *frame, int dest)
    data = "" &length);
    if (!data)
      {
-        fprintf(stderr, "No image data found for frame\n");
+        E("No image data found for frame\n");
         return 0;
      }
    while (length > 0)
@@ -364,7 +365,7 @@ get_loader(lopt * opt, ImlibLoader ** loader)
    data = "" const *)id3_field_getlatin1(field);
    if (!data)
      {
-        fprintf(stderr, "No mime type data found for image frame\n");
+        E("No mime type data found for image frame\n");
         return 0;
      }
    if (strncasecmp(data, "image/", 6))
@@ -374,14 +375,13 @@ get_loader(lopt * opt, ImlibLoader ** loader)
              *loader = NULL;
              return 1;
           }
-        fprintf(stderr,
-                "Picture frame with unknown mime-type \'%s\' found\n", data);
+        E("Picture frame with unknown mime-type \'%s\' found\n", data);
         return 0;
      }
    strncpy(ext + 1, data + 6, EXT_LEN);
    if (!(*loader = __imlib_FindBestLoader(ext, NULL, 0)))
      {
-        fprintf(stderr, "No loader found for extension %s\n", ext);
+        E("No loader found for extension %s\n", ext);
         return 0;
      }
    return 1;
@@ -518,7 +518,7 @@ _load(ImlibImage * im, int load_data)
 
         if ((dest = mkstemp(tmp)) < 0)
           {
-             fprintf(stderr, "Unable to create a temporary file\n");
+             E("Unable to create a temporary file\n");
              goto quit;
           }
 
@@ -551,7 +551,7 @@ _load(ImlibImage * im, int load_data)
         data = "" const *)id3_field_getbinarydata(field, &length);
         if (!data || !length)
           {
-             fprintf(stderr, "No link image URL present\n");
+             E("No link image URL present\n");
              goto quit;
           }
         url = "" *)malloc((length + 1) * sizeof(char));
@@ -560,7 +560,7 @@ _load(ImlibImage * im, int load_data)
         file = (strncmp(url, "file://", 7) ? url : url + 7);
         if (!(loader = __imlib_FindBestLoader(file, NULL, 0)))
           {
-             fprintf(stderr, "No loader found for file %s\n", file);
+             E("No loader found for file %s\n", file);
              free(url);
              goto quit;
           }
@@ -588,8 +588,7 @@ _load(ImlibImage * im, int load_data)
         fprintf(stderr, "Tags for file %s:\n", im->file);
         while (cur)
           {
-             fprintf(stderr, "\t%s: (%d) %s\n", cur->key,
-                     cur->val, (char *)cur->data);
+             E("\t%s: (%d) %s\n", cur->key, cur->val, (char *)cur->data);
              cur = cur->next;
           }
      }
diff --git a/src/modules/loaders/loader_tiff.c b/src/modules/loaders/loader_tiff.c
index e3ccc72..b2b10bd 100644
--- a/src/modules/loaders/loader_tiff.c
+++ b/src/modules/loaders/loader_tiff.c
@@ -378,7 +378,7 @@ _load(ImlibImage * im, int load_data)
 
    if (!rgba_image.rgba.put.any)
      {
-        fprintf(stderr, "imlib2-tiffloader: No put function");
+        E("No put function\n");
         goto quit;
      }
 
@@ -415,10 +415,7 @@ _load(ImlibImage * im, int load_data)
 
    rast = _TIFFmalloc(sizeof(uint32_t) * im->w * im->h);
    if (!rast)
-     {
-        fprintf(stderr, "imlib2-tiffloader: Out of memory\n");
-        QUIT_WITH_RC(LOAD_OOM);
-     }
+      QUIT_WITH_RC(LOAD_OOM);
 
    if (rgba_image.rgba.isContig)
      {
diff --git a/src/modules/loaders/loader_webp.c b/src/modules/loaders/loader_webp.c
index 5b74c2b..b35e801 100644
--- a/src/modules/loaders/loader_webp.c
+++ b/src/modules/loaders/loader_webp.c
@@ -133,20 +133,9 @@ _save(ImlibImage * im)
      {
         quality = quality_tag->val;
         if (quality < 0)
-          {
-             fprintf(stderr,
-                     "Warning: 'quality' setting %f too low for WebP, using 0\n",
-                     quality);
-             quality = 0;
-          }
-
-        if (quality > 100)
-          {
-             fprintf(stderr,
-                     "Warning, 'quality' setting %f too high for WebP, using 100\n",
-                     quality);
-             quality = 100;
-          }
+           quality = 0;
+        else if (quality > 100)
+           quality = 100;
      }
 
    encoded_size = WebPEncodeBGRA((uint8_t *) im->data, im->w, im->h,
diff --git a/src/modules/loaders/loader_xpm.c b/src/modules/loaders/loader_xpm.c
index 6726069..6f9cdbb 100644
--- a/src/modules/loaders/loader_xpm.c
+++ b/src/modules/loaders/loader_xpm.c
@@ -1,6 +1,8 @@
 #include "config.h"
 #include "Imlib2_Loader.h"
 
+#define DBG_PFX "LDR-xpm"
+
 static const char  *const _formats[] = { "xpm" };
 
 static struct {
@@ -230,21 +232,17 @@ _load(ImlibImage * im, int load_data)
                   sscanf(line, "%i %i %i %i", &w, &h, &ncolors, &cpp);
                   if ((ncolors > 32766) || (ncolors < 1))
                     {
-                       fprintf(stderr,
-                               "IMLIB ERROR: XPM files with colors > 32766 or < 1 not supported\n");
+                       E("XPM files with colors > 32766 or < 1 not supported\n");
                        goto quit;
                     }
                   if ((cpp > 5) || (cpp < 1))
                     {
-                       fprintf(stderr,
-                               "IMLIB ERROR: XPM files with characters per pixel > 5 or < 1 not supported\n");
+                       E("XPM files with characters per pixel > 5 or < 1 not supported\n");
                        goto quit;
                     }
                   if (!IMAGE_DIMENSIONS_OK(w, h))
                     {
-                       fprintf(stderr,
-                               "IMLIB ERROR: Invalid image dimension: %dx%d\n",
-                               w, h);
+                       E("Invalid image dimension: %dx%d\n", w, h);
                        goto quit;
                     }
                   im->w = w;

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to