[trunk] Remove some easy warnings about sign compare reported by gcc
authorMathieu Malaterre <mathieu.malaterre@gmail.com>
Thu, 6 Mar 2014 15:00:41 +0000 (15:00 +0000)
committerMathieu Malaterre <mathieu.malaterre@gmail.com>
Thu, 6 Mar 2014 15:00:41 +0000 (15:00 +0000)
src/bin/jp2/convert.c
src/lib/openjp2/jp2.c
tests/unit/testempty1.c
tests/unit/testempty2.c

index 23a3aecc0f81e9514d51cbdc3608e1adb1b3c3de..b4d9544e7cdc1effc4feff7c8633992b7f2f8d1d 100644 (file)
@@ -408,7 +408,8 @@ opj_image_t* tgatoimage(const char *filename, opj_cparameters_t *parameters) {
 int imagetotga(opj_image_t * image, const char *outfile) {
     int width, height, bpp, x, y;
     OPJ_BOOL write_alpha;
-    int i, adjustR, adjustG, adjustB, fails;
+    unsigned int i;
+    int adjustR, adjustG, adjustB, fails;
     unsigned int alpha_channel;
     float r,g,b,a;
     unsigned char value;
@@ -702,8 +703,8 @@ opj_image_t* bmptoimage(const char *filename, opj_cparameters_t *parameters)
         /* set image offset and reference grid */
         image->x0 = parameters->image_offset_x0;
         image->y0 = parameters->image_offset_y0;
-        image->x1 =    !image->x0 ? (w - 1) * subsampling_dx + 1 : image->x0 + (w - 1) * subsampling_dx + 1;
-        image->y1 =    !image->y0 ? (h - 1) * subsampling_dy + 1 : image->y0 + (h - 1) * subsampling_dy + 1;
+        image->x1 =    !image->x0 ? (w - 1) * subsampling_dx + 1 : (int)(image->x0 + (w - 1) * subsampling_dx + 1);
+        image->y1 =    !image->y0 ? (h - 1) * subsampling_dy + 1 : (int)(image->y0 + (h - 1) * subsampling_dy + 1);
 
         /* set image data */
 
@@ -803,8 +804,8 @@ opj_image_t* bmptoimage(const char *filename, opj_cparameters_t *parameters)
             /* set image offset and reference grid */
             image->x0 = parameters->image_offset_x0;
             image->y0 = parameters->image_offset_y0;
-            image->x1 =        !image->x0 ? (w - 1) * subsampling_dx + 1 : image->x0 + (w - 1) * subsampling_dx + 1;
-            image->y1 =        !image->y0 ? (h - 1) * subsampling_dy + 1 : image->y0 + (h - 1) * subsampling_dy + 1;
+            image->x1 =        !image->x0 ? (w - 1) * subsampling_dx + 1 : (int)(image->x0 + (w - 1) * subsampling_dx + 1);
+            image->y1 =        !image->y0 ? (h - 1) * subsampling_dy + 1 : (int)(image->y0 + (h - 1) * subsampling_dy + 1);
 
             /* set image data */
 
@@ -915,10 +916,8 @@ opj_image_t* bmptoimage(const char *filename, opj_cparameters_t *parameters)
                 /* set image offset and reference grid */
                 image->x0 = parameters->image_offset_x0;
                 image->y0 = parameters->image_offset_y0;
-                image->x1 = !image->x0 ? (w - 1) * subsampling_dx + 1 : image->x0 + (w
-                                                                                     - 1) * subsampling_dx + 1;
-                image->y1 = !image->y0 ? (h - 1) * subsampling_dy + 1 : image->y0 + (h
-                                                                                     - 1) * subsampling_dy + 1;
+                image->x1 = !image->x0 ? (w - 1) * subsampling_dx + 1 : (int)(image->x0 + (w - 1) * subsampling_dx + 1);
+                image->y1 = !image->y0 ? (h - 1) * subsampling_dy + 1 : (int)(image->y0 + (h - 1) * subsampling_dy + 1);
 
                 /* set image data */
 
@@ -1338,8 +1337,8 @@ opj_image_t* pgxtoimage(const char *filename, opj_cparameters_t *parameters) {
 
     cmptparm.x0 = parameters->image_offset_x0;
     cmptparm.y0 = parameters->image_offset_y0;
-    cmptparm.w = !cmptparm.x0 ? (w - 1) * parameters->subsampling_dx + 1 : cmptparm.x0 + (w - 1) * parameters->subsampling_dx + 1;
-    cmptparm.h = !cmptparm.y0 ? (h - 1) * parameters->subsampling_dy + 1 : cmptparm.y0 + (h - 1) * parameters->subsampling_dy + 1;
+    cmptparm.w = !cmptparm.x0 ? (w - 1) * parameters->subsampling_dx + 1 : (int)(cmptparm.x0 + (w - 1) * parameters->subsampling_dx + 1);
+    cmptparm.h = !cmptparm.y0 ? (h - 1) * parameters->subsampling_dy + 1 : (int)(cmptparm.y0 + (h - 1) * parameters->subsampling_dy + 1);
 
     if (sign == '-') {
         cmptparm.sgnd = 1;
@@ -1439,7 +1438,8 @@ static inline int clamp( const int value, const int prec, const int sgnd )
 int imagetopgx(opj_image_t * image, const char *outfile) 
 {
   int w, h;
-  int i, j, compno, fails = 1;
+  int i, j, fails = 1;
+  unsigned int compno;
   FILE *fdest = NULL;
 
   for (compno = 0; compno < image->numcomps; compno++) 
@@ -1938,7 +1938,8 @@ int imagetopnm(opj_image_t * image, const char *outfile)
 {
     int *red, *green, *blue, *alpha;
     int wr, hr, max;
-    int i, compno, ncomp;
+    int i;
+    unsigned int compno, ncomp;
     int adjustR, adjustG, adjustB, adjustA;
     int fails, two, want_gray, has_alpha, triple;
     int prec, v;
@@ -2701,9 +2702,9 @@ opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
         image->x0 = parameters->image_offset_x0;
         image->y0 = parameters->image_offset_y0;
         image->x1 =    !image->x0 ? (w - 1) * subsampling_dx + 1 :
-                                 image->x0 + (w - 1) * subsampling_dx + 1;
+                                 (int)(image->x0 + (w - 1) * subsampling_dx + 1);
         image->y1 =    !image->y0 ? (h - 1) * subsampling_dy + 1 :
-                                 image->y0 + (h - 1) * subsampling_dy + 1;
+                                 (int)(image->y0 + (h - 1) * subsampling_dy + 1);
 
         buf = _TIFFmalloc(TIFFStripSize(tif));
 
@@ -2851,9 +2852,9 @@ opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
         image->x0 = parameters->image_offset_x0;
         image->y0 = parameters->image_offset_y0;
         image->x1 =    !image->x0 ? (w - 1) * subsampling_dx + 1 :
-                                 image->x0 + (w - 1) * subsampling_dx + 1;
+                                 (int)(image->x0 + (w - 1) * subsampling_dx + 1);
         image->y1 =    !image->y0 ? (h - 1) * subsampling_dy + 1 :
-                                 image->y0 + (h - 1) * subsampling_dy + 1;
+                                 (int)(image->y0 + (h - 1) * subsampling_dy + 1);
 
         buf = _TIFFmalloc(TIFFStripSize(tif));
 
@@ -3046,7 +3047,7 @@ static int imagetoraw_common(opj_image_t * image, const char *outfile, OPJ_BOOL
 {
     FILE *rawFile = NULL;
     size_t res;
-    int compno;
+    unsigned int compno;
     int w, h, fails;
     int line, row, curr, mask;
     int *ptr;
index 87a32abc87935e89bd160370a4018e853f3ae815..4a6b346ec09d97719934fb496bc6f537f66bd29f 100644 (file)
@@ -1000,7 +1000,7 @@ OPJ_BOOL opj_jp2_read_pclr(       opj_jp2_t *jp2,
 
        for(j = 0; j < nr_entries; ++j) {
                for(i = 0; i < nr_channels; ++i) {
-                       OPJ_INT32 bytes_to_read = (channel_size[i]+7)>>3;
+                       OPJ_UINT32 bytes_to_read = (channel_size[i]+7)>>3;
 
                        if (bytes_to_read > sizeof(OPJ_UINT32))
                                bytes_to_read = sizeof(OPJ_UINT32);
index f4140f648e8e16b610232d0b09bbeab1432698a8..a2ae2d2d2ebb5518643434fb948cec9718be3a9b 100644 (file)
@@ -91,7 +91,7 @@ int main(int argc, char *argv[])
 
   for (i = 0; i < image_width * image_height; i++)
     {
-    int compno;
+    unsigned int compno;
     for(compno = 0; compno < numcomps; compno++)
       {
       image->comps[compno].data[i] = 0;
index 764b14cc1ffa00f9ff6cf1886b399963d7344b4a..abafa5b3571ed469d9d8f306b06c3d8e63558b37 100644 (file)
@@ -96,7 +96,7 @@ int main(int argc, char *argv[])
 
   for (i = 0; i < image_width * image_height; i++)
     {
-    int compno;
+    unsigned int compno;
     for(compno = 0; compno < numcomps; compno++)
       {
       image->comps[compno].data[i] = 0;