From 5743cca5f851a6c33462f66c2006ca5fc78f3c12 Mon Sep 17 00:00:00 2001 From: Mickael Savinaud Date: Fri, 29 Jul 2011 08:50:55 +0000 Subject: [PATCH] solve some obvious warnings for WIN platform, increase number of warning reported on the dashboard, correct last warnings with gcc 4.4 (-Wall) --- CHANGES | 3 +++ applications/codec/convert.c | 33 +++++++++++++++++++------------ applications/codec/image_to_j2k.c | 10 +++++----- applications/codec/j2k_dump.c | 18 ++++++++--------- applications/codec/j2k_to_image.c | 16 +++++++-------- applications/common/getopt.c | 2 +- applications/common/getopt.h | 2 +- libopenjpeg/event.c | 3 ++- libopenjpeg/jp2.c | 14 ++++++------- libopenjpeg/t2.c | 4 ++-- tests/comparePGXimages.c | 6 +++--- tests/compare_dump_files.c | 2 +- 12 files changed, 62 insertions(+), 51 deletions(-) diff --git a/CHANGES b/CHANGES index 26d8f3ff..319d9308 100644 --- 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 diff --git a/applications/codec/convert.c b/applications/codec/convert.c index c7adabe9..7b255092 100644 --- a/applications/codec/convert.c +++ b/applications/codec/convert.c @@ -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='+'; diff --git a/applications/codec/image_to_j2k.c b/applications/codec/image_to_j2k.c index e19ecdb7..92353970 100644 --- a/applications/codec/image_to_j2k.c +++ b/applications/codec/image_to_j2k.c @@ -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){ diff --git a/applications/codec/j2k_dump.c b/applications/codec/j2k_dump.c index 170c4324..b0f44043 100644 --- a/applications/codec/j2k_dump.c +++ b/applications/codec/j2k_dump.c @@ -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"); diff --git a/applications/codec/j2k_to_image.c b/applications/codec/j2k_to_image.c index 3da83119..2b421369 100644 --- a/applications/codec/j2k_to_image.c +++ b/applications/codec/j2k_to_image.c @@ -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"); diff --git a/applications/common/getopt.c b/applications/common/getopt.c index a02dde96..3edd969d 100644 --- a/applications/common/getopt.c +++ b/applications/common/getopt.c @@ -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; } diff --git a/applications/common/getopt.h b/applications/common/getopt.h index 779fe470..1b32d2b6 100644 --- a/applications/common/getopt.h +++ b/applications/common/getopt.h @@ -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_ */ diff --git a/libopenjpeg/event.c b/libopenjpeg/event.c index df684ba2..0dc22f12 100644 --- a/libopenjpeg/event.c +++ b/libopenjpeg/event.c @@ -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) { diff --git a/libopenjpeg/jp2.c b/libopenjpeg/jp2.c index ffbf270f..39d48a5f 100644 --- a/libopenjpeg/jp2.c +++ b/libopenjpeg/jp2.c @@ -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; diff --git a/libopenjpeg/t2.c b/libopenjpeg/t2.c index 4af8eb84..76821afc 100644 --- a/libopenjpeg/t2.c +++ b/libopenjpeg/t2.c @@ -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; } /* */ diff --git a/tests/comparePGXimages.c b/tests/comparePGXimages.c index dc3d9380..7a1e8f1c 100644 --- a/tests/comparePGXimages.c +++ b/tests/comparePGXimages.c @@ -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(" %d \n", it_comp, nbPixelDiff); printf(" %f \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); diff --git a/tests/compare_dump_files.c b/tests/compare_dump_files.c index 42ef2fbb..48b9d40f 100644 --- a/tests/compare_dump_files.c +++ b/tests/compare_dump_files.c @@ -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");