From b431cb0a41917d11d848d717e59403f45b673b8d Mon Sep 17 00:00:00 2001 From: Mathieu Malaterre Date: Wed, 18 Apr 2012 14:15:10 +0000 Subject: [PATCH] [1.5] fix compilation warnings on windows box --- CMakeLists.txt | 14 ++++---- libopenjpeg/jpwl/CMakeLists.txt | 2 +- tests/unit/testempty1.c | 39 ++++++++++++++++------ tests/unit/testempty2.c | 59 ++++++++++++++++++++++----------- 4 files changed, 77 insertions(+), 37 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7e222e24..e796bd34 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,13 +38,13 @@ SET(PACKAGE_VERSION # Because autotools does not support X.Y notation for SOVERSION, we have to use # two numerorations, one for the openjpeg version and one for openjpeg soversion # version | soversion -# 1.0 |  0 -# 1.1 |  1 -# 1.2 |  2 -# 1.3 |  3 -# 1.4 |  4 -# 1.5 |  5 -# 2.0 | 6 +# 1.0 | 0 +# 1.1 | 1 +# 1.2 | 2 +# 1.3 | 3 +# 1.4 | 4 +# 1.5 | 5 +# 2.0 | 6 # above is the recommendation by the OPJ team. If you really need to override this default, # you can specify your own OPENJPEG_SOVERSION at cmake configuration time: # cmake -DOPENJPEG_SOVERSION:STRING=42 /path/to/openjpeg diff --git a/libopenjpeg/jpwl/CMakeLists.txt b/libopenjpeg/jpwl/CMakeLists.txt index fff7d087..f6f20135 100644 --- a/libopenjpeg/jpwl/CMakeLists.txt +++ b/libopenjpeg/jpwl/CMakeLists.txt @@ -24,7 +24,7 @@ IF(WIN32) ENDIF(WIN32) ADD_LIBRARY(${OPENJPEG_LIBRARY_NAME}_JPWL ${JPWL_SRCS} ${OPENJPEG_SRCS}) IF(UNIX) - TARGET_LINK_LIBRARIES(${OPENJPEG_LIBRARY_NAME} m) + TARGET_LINK_LIBRARIES(${OPENJPEG_LIBRARY_NAME}_JPWL m) ENDIF(UNIX) SET_TARGET_PROPERTIES(${OPENJPEG_LIBRARY_NAME}_JPWL PROPERTIES ${OPENJPEG_LIBRARY_PROPERTIES}) diff --git a/tests/unit/testempty1.c b/tests/unit/testempty1.c index e2439d78..8f33f247 100644 --- a/tests/unit/testempty1.c +++ b/tests/unit/testempty1.c @@ -30,20 +30,29 @@ #define J2K_CFMT 0 +void error_callback(const char *msg, void *v); +void warning_callback(const char *msg, void *v); +void info_callback(const char *msg, void *v); + void error_callback(const char *msg, void *v) { +(void)msg; +(void)v; assert(0); } void warning_callback(const char *msg, void *v) { +(void)msg; +(void)v; puts(msg); } void info_callback(const char *msg, void *v) { +(void)msg; +(void)v; puts(msg); } int main(int argc, char *argv[]) { const char * v = opj_version(); - puts(v); const OPJ_COLOR_SPACE color_space = CLRSPC_GRAY; int numcomps = 1; @@ -52,13 +61,24 @@ int main(int argc, char *argv[]) int image_height = 256; opj_cparameters_t parameters; - opj_set_default_encoder_parameters(¶meters); - parameters.cod_format = J2K_CFMT; int subsampling_dx = 0; int subsampling_dy = 0; opj_image_cmptparm_t cmptparm; + opj_image_t *image; + opj_event_mgr_t event_mgr; + opj_cinfo_t* cinfo; + opj_cio_t *cio; + opj_bool bSuccess; + size_t codestream_length; + FILE *f; + (void)argc; + (void)argv; + + opj_set_default_encoder_parameters(¶meters); + parameters.cod_format = J2K_CFMT; + puts(v); cmptparm.prec = 8; cmptparm.bpp = 8; cmptparm.sgnd = 0; @@ -67,7 +87,7 @@ int main(int argc, char *argv[]) cmptparm.w = image_width; cmptparm.h = image_height; - opj_image_t *image = opj_image_create(numcomps, &cmptparm, color_space); + image = opj_image_create(numcomps, &cmptparm, color_space); assert( image ); for (i = 0; i < image_width * image_height; i++) @@ -79,26 +99,25 @@ int main(int argc, char *argv[]) } } - opj_event_mgr_t event_mgr; event_mgr.error_handler = error_callback; event_mgr.warning_handler = warning_callback; event_mgr.info_handler = info_callback; - opj_cinfo_t* cinfo = opj_create_compress(CODEC_J2K); + cinfo = opj_create_compress(CODEC_J2K); opj_set_event_mgr((opj_common_ptr)cinfo, &event_mgr, stderr); opj_setup_encoder(cinfo, ¶meters, image); - opj_cio_t *cio = opj_cio_open((opj_common_ptr)cinfo, NULL, 0); + cio = opj_cio_open((opj_common_ptr)cinfo, NULL, 0); assert( cio ); - opj_bool bSuccess = opj_encode(cinfo, cio, image, NULL); + bSuccess = opj_encode(cinfo, cio, image, NULL); assert( bSuccess ); - size_t codestream_length = cio_tell(cio); + codestream_length = (size_t)cio_tell(cio); assert( codestream_length ); strcpy(parameters.outfile, "testempty1.j2k"); - FILE *f = fopen(parameters.outfile, "wb"); + f = fopen(parameters.outfile, "wb"); assert( f ); fwrite(cio->buffer, 1, codestream_length, f); fclose(f); diff --git a/tests/unit/testempty2.c b/tests/unit/testempty2.c index 813a3e5b..7d1ed683 100644 --- a/tests/unit/testempty2.c +++ b/tests/unit/testempty2.c @@ -23,7 +23,6 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ - #include #include #include @@ -32,20 +31,29 @@ #define J2K_CFMT 0 +void error_callback(const char *msg, void *v); +void warning_callback(const char *msg, void *v); +void info_callback(const char *msg, void *v); + void error_callback(const char *msg, void *v) { +(void)msg; +(void)v; assert(0); } void warning_callback(const char *msg, void *v) { +(void)msg; +(void)v; puts(msg); } void info_callback(const char *msg, void *v) { +(void)msg; +(void)v; puts(msg); } int main(int argc, char *argv[]) { const char * v = opj_version(); - puts(v); const OPJ_COLOR_SPACE color_space = CLRSPC_GRAY; int numcomps = 1; @@ -54,13 +62,25 @@ int main(int argc, char *argv[]) int image_height = 256; opj_cparameters_t parameters; - opj_set_default_encoder_parameters(¶meters); - parameters.cod_format = J2K_CFMT; int subsampling_dx = parameters.subsampling_dx; int subsampling_dy = parameters.subsampling_dy; + const char outputfile[] = "testempty2.j2k"; opj_image_cmptparm_t cmptparm; + opj_image_t *image; + opj_event_mgr_t event_mgr; + opj_cinfo_t* cinfo; + opj_cio_t *cio; + opj_bool bSuccess; + size_t codestream_length; + FILE *f; + (void)argc; + (void)argv; + + opj_set_default_encoder_parameters(¶meters); + parameters.cod_format = J2K_CFMT; + puts(v); cmptparm.prec = 8; cmptparm.bpp = 8; cmptparm.sgnd = 0; @@ -69,7 +89,7 @@ int main(int argc, char *argv[]) cmptparm.w = image_width; cmptparm.h = image_height; - opj_image_t *image = opj_image_create(numcomps, &cmptparm, color_space); + image = opj_image_create(numcomps, &cmptparm, color_space); assert( image ); for (i = 0; i < image_width * image_height; i++) @@ -81,27 +101,25 @@ int main(int argc, char *argv[]) } } - opj_event_mgr_t event_mgr; event_mgr.error_handler = error_callback; event_mgr.warning_handler = warning_callback; event_mgr.info_handler = info_callback; - opj_cinfo_t* cinfo = opj_create_compress(CODEC_J2K); + cinfo = opj_create_compress(CODEC_J2K); opj_set_event_mgr((opj_common_ptr)cinfo, &event_mgr, stderr); opj_setup_encoder(cinfo, ¶meters, image); - opj_cio_t *cio = opj_cio_open((opj_common_ptr)cinfo, NULL, 0); + cio = opj_cio_open((opj_common_ptr)cinfo, NULL, 0); assert( cio ); - opj_bool bSuccess = opj_encode(cinfo, cio, image, NULL); + bSuccess = opj_encode(cinfo, cio, image, NULL); assert( bSuccess ); - size_t codestream_length = cio_tell(cio); + codestream_length = (size_t)cio_tell(cio); assert( codestream_length ); - const char outputfile[] = "testempty2.j2k"; strcpy(parameters.outfile, outputfile); - FILE *f = fopen(parameters.outfile, "wb"); + f = fopen(parameters.outfile, "wb"); assert( f ); fwrite(cio->buffer, 1, codestream_length, f); fclose(f); @@ -111,13 +129,17 @@ int main(int argc, char *argv[]) opj_image_destroy(image); /* read back the generated file */ +{ size_t file_length; FILE *fsrc = fopen(outputfile, "rb"); + unsigned char *src; + opj_dinfo_t* dinfo = NULL; /* handle to a decompressor */ + opj_dparameters_t dparameters; assert( fsrc ); fseek(fsrc, 0, SEEK_END); - file_length = ftell(fsrc); + file_length = (size_t)ftell(fsrc); fseek(fsrc, 0, SEEK_SET); - unsigned char *src = (unsigned char *) malloc(file_length); + src = (unsigned char *) malloc(file_length); if (fread(src, 1, file_length, fsrc) != file_length) { free(src); @@ -126,24 +148,23 @@ int main(int argc, char *argv[]) } fclose(fsrc); - opj_dinfo_t* dinfo = NULL; /* handle to a decompressor */ dinfo = opj_create_decompress(CODEC_J2K); opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, stderr); - opj_dparameters_t dparameters; opj_set_default_decoder_parameters(&dparameters); opj_setup_decoder(dinfo, &dparameters); - cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length); + cio = opj_cio_open((opj_common_ptr)dinfo, src, (int)file_length); image = opj_decode(dinfo, cio); if(!image) { opj_destroy_decompress(dinfo); opj_cio_close(cio); return 1; } - opj_destroy_decompress(dinfo); - opj_cio_close(cio); + opj_destroy_decompress(dinfo); + opj_cio_close(cio); +} puts( "end" );