solve some obvious warnings for WIN platform, increase number of warning reported...
authorMickael Savinaud <savmickael@users.noreply.github.com>
Fri, 29 Jul 2011 08:50:55 +0000 (08:50 +0000)
committerMickael Savinaud <savmickael@users.noreply.github.com>
Fri, 29 Jul 2011 08:50:55 +0000 (08:50 +0000)
12 files changed:
CHANGES
applications/codec/convert.c
applications/codec/image_to_j2k.c
applications/codec/j2k_dump.c
applications/codec/j2k_to_image.c
applications/common/getopt.c
applications/common/getopt.h
libopenjpeg/event.c
libopenjpeg/jp2.c
libopenjpeg/t2.c
tests/comparePGXimages.c
tests/compare_dump_files.c

diff --git a/CHANGES b/CHANGES
index 26d8f3ff9ae6d94c29dffe2bf8ca8dc95fac4efc..319d930887d580994f5eba51ec838db2828393fe 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -5,6 +5,9 @@ What's New for OpenJPEG
 ! : changed
 + : added
 
+July 29, 2011
+! [mickael] solve some obvious warnings for WIN platform, increase number of warning reported on the dashboard, correct last warnings with gcc 4.4 (-Wall)
+
 July 27, 2011
 ! [mickael] added new decoding/dump tests based on data found in input/nonregresion repository (remove JPEG2000_CONFORMANCE_DATA_ROOT variable, add REF_DECODER_BIN_PATH variable for the encoder test suite). Remove definitively old tests. 
 ! [mickael] correct some warnings detected under unix platform
index c7adabe99559f48f13ed307c9c577da604452b93..7b255092baaf737fe09b2d206e06fb2ec4e64f64 100644 (file)
@@ -158,9 +158,14 @@ int tga_writeheader(FILE *fp, int bits_per_pixel, int width, int height,
 
        memset(&tga, 0, sizeof(tga_header));
 
-       tga.pixel_depth = bits_per_pixel;
-       tga.image_width  = width;
-       tga.image_height = height;
+       if ( bits_per_pixel < 256 )
+               tga.pixel_depth = (unsigned char)bits_per_pixel;
+       else{
+               fprintf(stderr,"ERROR: Wrong bits per pixel inside tga_header");
+               return 0;
+       }
+       tga.image_width  = (unsigned short)width;
+       tga.image_height = (unsigned short)height;
        tga.image_type = 2; // Uncompressed.
        tga.image_desc = 8; // 8 bits per component.
 
@@ -639,9 +644,9 @@ opj_image_t* bmptoimage(const char *filename, opj_cparameters_t *parameters)
        has_color = 0;  
        for (j = 0; j < Info_h.biClrUsed; j++) 
   {
-       table_B[j] = getc(IN);
-       table_G[j] = getc(IN);
-       table_R[j] = getc(IN);
+       table_B[j] = (unsigned char)getc(IN);
+       table_G[j] = (unsigned char)getc(IN);
+       table_R[j] = (unsigned char)getc(IN);
        getc(IN);
        has_color += 
         !(table_R[j] == table_G[j] && table_R[j] == table_B[j]);
@@ -757,9 +762,9 @@ opj_image_t* bmptoimage(const char *filename, opj_cparameters_t *parameters)
                has_color = 0;
                for (j = 0; j < Info_h.biClrUsed; j++)
                {
-                       table_B[j] = getc(IN);
-                       table_G[j] = getc(IN);
-                       table_R[j] = getc(IN);
+                       table_B[j] = (unsigned char)getc(IN);
+                       table_G[j] = (unsigned char)getc(IN);
+                       table_R[j] = (unsigned char)getc(IN);
                        getc(IN);
                        has_color += !(table_R[j] == table_G[j] && table_R[j] == table_B[j]);
                }
@@ -822,7 +827,7 @@ opj_image_t* bmptoimage(const char *filename, opj_cparameters_t *parameters)
                                c1 = getc(IN);
 
                                for (i = 0; i < c && x < W && pix < beyond; i++, x++, pix++)
-                                       *pix = c1;
+                                       *pix = (unsigned char)c1;
                        }
                        else
                        {
@@ -850,7 +855,7 @@ opj_image_t* bmptoimage(const char *filename, opj_cparameters_t *parameters)
                                        for (; i < c && x < W && pix < beyond; i++, x++, pix++)
                                        {
                                                c1 = getc(IN);
-                                               *pix = c1;
+                                               *pix = (unsigned char)c1;
                                        }
                                        if (c & 1) /* skip padding byte */
                                                getc(IN);
@@ -1187,8 +1192,10 @@ opj_image_t* pgxtoimage(const char *filename, opj_cparameters_t *parameters) {
        }
 
        fseek(f, 0, SEEK_SET);
-       fscanf(f, "PG%[ \t]%c%c%[ \t+-]%d%[ \t]%d%[ \t]%d",temp,&endian1,&endian2,signtmp,&prec,temp,&w,temp,&h);
-       
+       if( fscanf(f, "PG%[ \t]%c%c%[ \t+-]%d%[ \t]%d%[ \t]%d",temp,&endian1,&endian2,signtmp,&prec,temp,&w,temp,&h) != 9){
+               fprintf(stderr, "ERROR: Failed to read the right number of element from the fscanf() function!\n");
+               return NULL;
+       }
 
        i=0;
        sign='+';               
index e19ecdb7900c6136b25dc0476e8decc7cc91206f..92353970ebd974ec84480b574c2e104bca255a16 100644 (file)
@@ -82,7 +82,7 @@ typedef struct img_folder{
        float *rates;
 }img_fol_t;
 
-void encode_help_display() {
+void encode_help_display(void) {
        fprintf(stdout,"HELP for image_to_j2k\n----\n\n");
        fprintf(stdout,"- the -h option displays this help information on screen\n\n");
 
@@ -573,7 +573,7 @@ void cinema_setup_encoder(opj_cparameters_t *parameters,opj_image_t *image, img_
 
 int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
                                                                                                        img_fol_t *img_fol, raw_cparameters_t *raw_cp, char *indexfilename) {
-       int i, j,totlen;
+       int i, j, totlen, c;
        option_t long_option[]={
                {"cinema2K",REQ_ARG, NULL ,'w'},
                {"cinema4K",NO_ARG, NULL ,'y'},
@@ -597,8 +597,8 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
        img_fol->set_out_format=0;
        raw_cp->rawWidth = 0;
 
-       while (1) {
-    int c = getopt_long(argc, argv, optlist,long_option,totlen);
+       do{
+               c = getopt_long(argc, argv, optlist,long_option,totlen);
                if (c == -1)
                        break;
                switch (c) {
@@ -1376,7 +1376,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
                                fprintf(stderr, "ERROR -> Command line not valid\n");
                                return 1;
                }
-       }
+       }while(c != -1);
 
        /* check for possible errors */
        if (parameters->cp_cinema){
index 170c4324922c64d6726a22420c4e0622fea82d2d..b0f4404333af5626ba232dc715a5f086ebf78f78 100644 (file)
@@ -73,7 +73,7 @@ typedef struct img_folder{
 
 }img_fol_t;
 
-void decode_help_display() {
+void decode_help_display(void) {
        fprintf(stdout,"HELP for j2k_dump\n----\n\n");
        fprintf(stdout,"- the -h option displays this help information on screen\n\n");
 
@@ -196,7 +196,7 @@ char get_next_file(int imageno,dircnt_t *dirptr,img_fol_t *img_fol, opj_dparamet
 /* -------------------------------------------------------------------------- */
 int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,img_fol_t *img_fol, char *indexfilename) {
        /* parse the command line */
-       int totlen;
+       int totlen, c;
        option_t long_option[]={
                {"ImgDir",REQ_ARG, NULL ,'y'},
        };
@@ -204,8 +204,8 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
        const char optlist[] = "i:o:h";
        totlen=sizeof(long_option);
        img_fol->set_out_format = 0;
-       while (1) {
-               int c = getopt_long(argc, argv,optlist,long_option,totlen);
+       do {
+               c = getopt_long(argc, argv,optlist,long_option,totlen);
                if (c == -1)
                        break;
                switch (c) {
@@ -259,7 +259,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
                                fprintf(stderr,"WARNING -> this option is not valid \"-%c %s\"\n",c, optarg);
                                break;
                }
-       }
+       }while(c != -1);
 
        /* check for possible errors */
        if(img_fol->set_imgdir==1){
@@ -412,7 +412,7 @@ int main(int argc, char *argv[])
                file_length = ftell(fsrc);
                fseek(fsrc, 0, SEEK_SET);
                src = (unsigned char *) malloc(file_length);
-               if (fread(src, 1, file_length, fsrc) != file_length)
+               if (fread(src, 1, file_length, fsrc) != (size_t)file_length)
                {
                        free(src);
                        fclose(fsrc);
@@ -463,7 +463,7 @@ int main(int argc, char *argv[])
 
                        /* Write the index to disk */
                        if (*indexfilename) {
-                               char bSuccess;
+                               opj_bool bSuccess;
                                bSuccess = write_index_file(&cstr_info, indexfilename);
                                if (bSuccess) {
                                        fprintf(stderr, "Failed to output index file\n");
@@ -514,7 +514,7 @@ int main(int argc, char *argv[])
 
                        /* Write the index to disk */
                        if (*indexfilename) {
-                               char bSuccess;
+                               opj_bool bSuccess;
                                bSuccess = write_index_file(&cstr_info, indexfilename);
                                if (bSuccess) {
                                        fprintf(stderr, "Failed to output index file\n");
@@ -556,7 +556,7 @@ int main(int argc, char *argv[])
 
                        /* Write the index to disk */
                        if (*indexfilename) {
-                               char bSuccess;
+                               opj_bool bSuccess;
                                bSuccess = write_index_file(&cstr_info, indexfilename);
                                if (bSuccess) {
                                        fprintf(stderr, "Failed to output index file\n");
index 3da8311922dd053a1d168b46ba74dd605899b81a..2b4213693874d43b3fe55d1d8a4136727fde3705 100644 (file)
@@ -85,7 +85,7 @@ typedef struct img_folder{
 
 }img_fol_t;
 
-void decode_help_display() {
+void decode_help_display(void) {
        fprintf(stdout,"HELP for j2k_to_image\n----\n\n");
        fprintf(stdout,"- the -h option displays this help information on screen\n\n");
 
@@ -237,7 +237,7 @@ char get_next_file(int imageno,dircnt_t *dirptr,img_fol_t *img_fol, opj_dparamet
 /* -------------------------------------------------------------------------- */
 int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,img_fol_t *img_fol, char *indexfilename) {
        /* parse the command line */
-       int totlen;
+       int totlen, c;
        option_t long_option[]={
                {"ImgDir",REQ_ARG, NULL ,'y'},
                {"OutFor",REQ_ARG, NULL ,'O'},
@@ -253,8 +253,8 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
                        "h"             ;
        totlen=sizeof(long_option);
        img_fol->set_out_format = 0;
-       while (1) {
-               int c = getopt_long(argc, argv,optlist,long_option,totlen);
+       do {
+               c = getopt_long(argc, argv,optlist,long_option,totlen);
                if (c == -1)
                        break;
                switch (c) {
@@ -457,7 +457,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
                                fprintf(stderr,"WARNING -> this option is not valid \"-%c %s\"\n",c, optarg);
                                break;
                }
-       }
+       }while(c != -1);
 
        /* check for possible errors */
        if(img_fol->set_imgdir==1){
@@ -641,7 +641,7 @@ int main(int argc, char **argv) {
 
                        /* Write the index to disk */
                        if (*indexfilename) {
-                               char bSuccess;
+                               opj_bool bSuccess;
                                bSuccess = write_index_file(&cstr_info, indexfilename);
                                if (bSuccess) {
                                        fprintf(stderr, "Failed to output index file\n");
@@ -683,7 +683,7 @@ int main(int argc, char **argv) {
 
                        /* Write the index to disk */
                        if (*indexfilename) {
-                               char bSuccess;
+                               opj_bool bSuccess;
                                bSuccess = write_index_file(&cstr_info, indexfilename);
                                if (bSuccess) {
                                        fprintf(stderr, "Failed to output index file\n");
@@ -725,7 +725,7 @@ int main(int argc, char **argv) {
 
                        /* Write the index to disk */
                        if (*indexfilename) {
-                               char bSuccess;
+                               opj_bool bSuccess;
                                bSuccess = write_index_file(&cstr_info, indexfilename);
                                if (bSuccess) {
                                        fprintf(stderr, "Failed to output index file\n");
index a02dde9677bd1bf78204ee7cff9e56d4e7828c9f..3edd969d94f8b090a55ea7eb07a36bf067571c21 100644 (file)
@@ -60,7 +60,7 @@ typedef struct option
 #define        EMSG    ""
 
 /* As this class remembers its values from one Java call to the other, reset the values before each use */
-void reset_options_reading() {
+void reset_options_reading(void) {
        opterr = 1;
        optind = 1;
 }
index 779fe470b399019356eedf3f518b23a28402c915..1b32d2b67bd75ca97c328886de800c7b09065979 100644 (file)
@@ -24,6 +24,6 @@ extern char *optarg;
 extern int getopt(int nargc, char *const *nargv, const char *ostr);
 extern int getopt_long(int argc, char * const argv[], const char *optstring,
                        const struct option *longopts, int totlen);
-extern void reset_options_reading();
+extern void reset_options_reading(void);
 
 #endif                         /* _GETOPT_H_ */
index df684ba23d436fa4404db8d9aecb5009a436753f..0dc22f125499182ee54e1c84728c3f5838ac2d21 100644 (file)
@@ -30,6 +30,7 @@
      Utility functions
    ==========================================================*/
 
+#ifdef OPJ_CODE_NOT_USED
 #ifndef _WIN32
 static char*
 i2a(unsigned i, char *a, unsigned r) {
@@ -58,7 +59,7 @@ _itoa(int i, char *a, int r) {
 }
 
 #endif /* !_WIN32 */
-
+#endif
 /* ----------------------------------------------------------------------- */
 
 opj_event_mgr_t* OPJ_CALLCONV opj_set_event_mgr(opj_common_ptr cinfo, opj_event_mgr_t *event_mgr, void *context) {
index ffbf270fb6506b3e797567dcddb11555f8d02fc2..39d48a5fbe6c778fc39a8644278cf1aedf0ac9c5 100644 (file)
@@ -403,8 +403,8 @@ static opj_bool jp2_read_pclr(opj_jp2_t *jp2, opj_cio_t *cio,
 */
        if(color->jp2_pclr) return OPJ_FALSE;
 
-       nr_entries = cio_read(cio, 2); /* NE */
-       nr_channels = cio_read(cio, 1);/* NPC */
+       nr_entries = (unsigned short)cio_read(cio, 2); /* NE */
+       nr_channels = (unsigned short)cio_read(cio, 1);/* NPC */
 
        entries = (unsigned int*)
         opj_malloc(nr_channels * nr_entries * sizeof(unsigned int));
@@ -460,7 +460,7 @@ static opj_bool jp2_read_cmap(opj_jp2_t *jp2, opj_cio_t *cio,
 
        for(i = 0; i < nr_channels; ++i)
    {
-       cmap[i].cmp = cio_read(cio, 2);
+       cmap[i].cmp = (unsigned short)cio_read(cio, 2);
        cmap[i].mtyp = cio_read(cio, 1);
        cmap[i].pcol = cio_read(cio, 1);
 
@@ -516,7 +516,7 @@ static opj_bool jp2_read_cdef(opj_jp2_t *jp2, opj_cio_t *cio,
 */
        if(color->jp2_cdef) return OPJ_FALSE;
 
-       if((n = cio_read(cio, 2)) == 0) return OPJ_FALSE; /* szukw000: FIXME */
+       if((n = (unsigned short)cio_read(cio, 2)) == 0) return OPJ_FALSE; /* szukw000: FIXME */
 
        info = (opj_jp2_cdef_info_t*)
         opj_malloc(n * sizeof(opj_jp2_cdef_info_t));
@@ -527,9 +527,9 @@ static opj_bool jp2_read_cdef(opj_jp2_t *jp2, opj_cio_t *cio,
 
        for(i = 0; i < n; ++i)
    {
-       info[i].cn = cio_read(cio, 2);
-       info[i].typ = cio_read(cio, 2);
-       info[i].asoc = cio_read(cio, 2);
+       info[i].cn = (unsigned short)cio_read(cio, 2);
+       info[i].typ = (unsigned short)cio_read(cio, 2);
+       info[i].asoc = (unsigned short)cio_read(cio, 2);
 
    }
        return OPJ_TRUE;
index 4af8eb84ca698687298665b7dbc339bf7f05ecb0..76821afcd5b8a669c80ea027956426d67cc2dd75 100644 (file)
@@ -149,8 +149,8 @@ static int t2_encode_packet(opj_tcd_tile_t * tile, opj_tcp_t * tcp, opj_pi_itera
                c[1] = 145;
                c[2] = 0;
                c[3] = 4;
-               c[4] = (tile->packno % 65536) / 256;
-               c[5] = (tile->packno % 65536) % 256;
+               c[4] = (unsigned char)((tile->packno % 65536) / 256);
+               c[5] = (unsigned char)((tile->packno % 65536) % 256);
                c += 6;
        }
        /* </SOP> */
index dc3d938077880a5f0c8b99f07e2d9012d6277ff2..7a1e8f1c319c7f6d9a4c0ee874f017a5b4d57bcc 100644 (file)
@@ -19,7 +19,7 @@
 #include "convert.h"
 
 double* parseToleranceValues( char* inArg, const int nbcomp);
-void comparePGXimages_help_display();
+void comparePGXimages_help_display(void);
 opj_image_t* readImageFromFilePGX(char* filename, int nbFilenamePGX, char *separator);
 #ifdef HAVE_LIBPNG
 int imageToPNG(const opj_image_t* image, const char* filename, int num_comp_select);
@@ -49,7 +49,7 @@ typedef struct test_cmp_parameters
 /*******************************************************************************
  * Command line help function
  *******************************************************************************/
-void comparePGXimages_help_display() {
+void comparePGXimages_help_display(void) {
   fprintf(stdout,"\nList of parameters for the comparePGX function  \n");
   fprintf(stdout,"\n");
   fprintf(stdout,"  -b \t REQUIRED \t filename to the reference/baseline PGX image \n");
@@ -713,12 +713,12 @@ int main(int argc, char **argv)
        if ( nbPixelDiff > 0)
          {
          char it_compc[255];
+         it_compc[0] = '\0';
 
          printf("<DartMeasurement name=\"NumberOfPixelsWithDifferences_%d\" type=\"numeric/int\"> %d </DartMeasurement> \n", it_comp, nbPixelDiff);
          printf("<DartMeasurement name=\"ComponentError_%d\" type=\"numeric/double\"> %f </DartMeasurement> \n", it_comp, sumDiff);
 
 #ifdef HAVE_LIBPNG
-         it_compc[0] = '\0';
          sprintf(it_compc, "_%i", it_comp);
          strcat(it_compc,".png");
          strcat(filenamePNGbase_it_comp, it_compc);
index 42ef2fbb33f841ba4991a4e45ca4b19104b54dcc..48b9d40fc40cb53c34f40d0cdf6c9a9c15c1d541 100644 (file)
@@ -24,7 +24,7 @@ typedef struct test_cmp_parameters
 /*******************************************************************************
  * Command line help function
  *******************************************************************************/
-void compare_dump_files_help_display() {
+void compare_dump_files_help_display(void) {
   fprintf(stdout,"\nList of parameters for the compare_dump_files function  \n");
   fprintf(stdout,"\n");
   fprintf(stdout,"  -b \t REQUIRED \t filename to the reference/baseline dump file \n");