]> granicus.if.org Git - openjpeg/commitdiff
convert.c: fix recently introduced -Wsign-conversion warnings
authorEven Rouault <even.rouault@spatialys.com>
Thu, 17 Aug 2017 15:02:40 +0000 (17:02 +0200)
committerEven Rouault <even.rouault@spatialys.com>
Thu, 17 Aug 2017 15:02:40 +0000 (17:02 +0200)
src/bin/jp2/convert.c

index 73dfc8d5fd79adc6238ca0923b179c0cad15263c..deb4641e45364e71fe717f7b991f34f193621200 100644 (file)
@@ -583,7 +583,7 @@ struct tga_header {
 /* Returns a ushort from a little-endian serialized value */
 static unsigned short get_tga_ushort(const unsigned char *data)
 {
-    return data[0] | (data[1] << 8);
+    return (unsigned short)data[0] | (unsigned short)(data[1] << 8);
 }
 
 #define TGA_HEADER_SIZE 18
@@ -816,10 +816,11 @@ opj_image_t* tgatoimage(const char *filename, opj_cparameters_t *parameters)
 
     /* If the declared file size is > 10 MB, check that the file is big */
     /* enough to avoid excessive memory allocations */
-    if (image_height != 0 && image_width > 10000000 / image_height / numcomps) {
+    if (image_height != 0 &&
+            image_width > 10000000U / image_height / (OPJ_UINT32)numcomps) {
         char ch;
         OPJ_UINT64 expected_file_size =
-            (OPJ_UINT64)image_width * image_height * numcomps;
+            (OPJ_UINT64)image_width * image_height * (OPJ_UINT32)numcomps;
         long curpos = ftell(f);
         if (expected_file_size > (OPJ_UINT64)INT_MAX) {
             expected_file_size = (OPJ_UINT64)INT_MAX;