shithub: jbig2

Download patch

ref: 6bb88b8d16a0bd10387e06adbcf914a44cb766c6
parent: 9d7b467d807844ab3d13e9d9f518bac58efc5620
author: Tor Andersson <[email protected]>
date: Thu Mar 29 08:56:07 EDT 2018

Fix signed/unsigned comparison warnings.

--- a/Makefile.unix
+++ b/Makefile.unix
@@ -4,7 +4,7 @@
 
 prefix ?= /usr/local
 
-CFLAGS := -Wall -g -O2 -DHAVE_STDINT_H
+CFLAGS := -Wall -Wextra -Wno-unused-parameter -g -O2
 
 LIB_SRCS := \
 	jbig2_arith.c jbig2_arith_int.c jbig2_arith_iaid.c \
--- a/jbig2_huffman.c
+++ b/jbig2_huffman.c
@@ -351,7 +351,7 @@
     const Jbig2HuffmanLine *lines = params->lines;
     int n_lines = params->n_lines;
     int i, j;
-    int max_j;
+    uint32_t max_j;
     int log_table_size = 0;
     Jbig2HuffmanTable *result;
     Jbig2HuffmanEntry *entries;
@@ -423,6 +423,7 @@
                 int RANGELEN = lines[CURTEMP].RANGELEN;
                 uint32_t start_j = CURCODE << shift;
                 uint32_t end_j = (CURCODE + 1) << shift;
+                uint32_t cur_j;
                 byte eflags = 0;
 
                 if (end_j > max_j) {
@@ -438,23 +439,23 @@
                 if (CURTEMP == n_lines - (params->HTOOB ? 3 : 2))
                     eflags |= JBIG2_HUFFMAN_FLAGS_ISLOW;
                 if (PREFLEN + RANGELEN > LOG_TABLE_SIZE_MAX) {
-                    for (j = start_j; j < end_j; j++) {
-                        entries[j].u.RANGELOW = lines[CURTEMP].RANGELOW;
-                        entries[j].PREFLEN = PREFLEN;
-                        entries[j].RANGELEN = RANGELEN;
-                        entries[j].flags = eflags;
+                    for (cur_j = start_j; cur_j < end_j; cur_j++) {
+                        entries[cur_j].u.RANGELOW = lines[CURTEMP].RANGELOW;
+                        entries[cur_j].PREFLEN = PREFLEN;
+                        entries[cur_j].RANGELEN = RANGELEN;
+                        entries[cur_j].flags = eflags;
                     }
                 } else {
-                    for (j = start_j; j < end_j; j++) {
-                        int32_t HTOFFSET = (j >> (shift - RANGELEN)) & ((1 << RANGELEN) - 1);
+                    for (cur_j = start_j; cur_j < end_j; cur_j++) {
+                        int32_t HTOFFSET = (cur_j >> (shift - RANGELEN)) & ((1 << RANGELEN) - 1);
 
                         if (eflags & JBIG2_HUFFMAN_FLAGS_ISLOW)
-                            entries[j].u.RANGELOW = lines[CURTEMP].RANGELOW - HTOFFSET;
+                            entries[cur_j].u.RANGELOW = lines[CURTEMP].RANGELOW - HTOFFSET;
                         else
-                            entries[j].u.RANGELOW = lines[CURTEMP].RANGELOW + HTOFFSET;
-                        entries[j].PREFLEN = PREFLEN + RANGELEN;
-                        entries[j].RANGELEN = 0;
-                        entries[j].flags = eflags;
+                            entries[cur_j].u.RANGELOW = lines[CURTEMP].RANGELOW + HTOFFSET;
+                        entries[cur_j].PREFLEN = PREFLEN + RANGELEN;
+                        entries[cur_j].RANGELEN = 0;
+                        entries[cur_j].flags = eflags;
                     }
                 }
                 CURCODE++;
--- a/jbig2_image_png.c
+++ b/jbig2_image_png.c
@@ -98,7 +98,7 @@
 int
 jbig2_image_write_png(Jbig2Image *image, FILE *out)
 {
-    int i;
+    uint32_t i;
     png_structp png;
     png_infop info;
     png_bytep rowpointer;
--- a/jbig2_mmr.c
+++ b/jbig2_mmr.c
@@ -944,7 +944,7 @@
             /* printf ("VR(3)\n"); */
             jbig2_decode_mmr_consume(mmr, 7);
             b1 = jbig2_find_changing_element_of_color(ref, a0, mmr->width, !c);
-            if (b1 + 3 > (int)mmr->width)
+            if (b1 + 3 > mmr->width)
                 break;
             if (c) {
                 if (a0 == MINUS1 || b1 + 3 < a0)