From 4935eaf773d49df92cea4845c52ff45d4a17ed1e Mon Sep 17 00:00:00 2001 From: Mathieu Malaterre Date: Fri, 24 Aug 2012 08:13:17 +0000 Subject: [PATCH] [1.5] COMP: Fix warnings identified by clang31 openjpeg/libopenjpeg/tcd.c:1884 col 48: warning: comparison of unsigned expressi on < 0 is always false openjpeg/applications/codec/j2k_dump.c:362 col 29: warning: equality comparison with extraneous parentheses openjpeg/libopenjpeg/jpwl/jpwl_lib.c:680:19: warning: format specifies type 'int ' but the argument has type 'long long' [-Wformat] printf("Marker@%d: %X\n", cio_tell(cio) - 2, id); ~^ ~~~~~~~~~~~~~~~~~ %lld openjpeg/applications/jpip/libopenjpip/byte_manager.c:58:63: warning: format spe cifies type 'long' but the argument has type 'OPJ_OFF_T' (aka 'long long') [-Wfo rmat] fprintf( FCGI_stderr, "Error: error in fetch_bytes( %d, %ld, %lu)\n", fd, offset , size); Author: Hans Johnson --- applications/codec/j2k_dump.c | 4 ++-- applications/jpip/libopenjpip/byte_manager.c | 10 +++++----- libopenjpeg/jpwl/jpwl_lib.c | 2 +- libopenjpeg/tcd.c | 8 +++++--- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/applications/codec/j2k_dump.c b/applications/codec/j2k_dump.c index ed250e83..60b8c3c8 100644 --- a/applications/codec/j2k_dump.c +++ b/applications/codec/j2k_dump.c @@ -274,12 +274,12 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i fprintf(stderr, "Only one format allowed! Valid format PGM, PPM, PNM, PGX, BMP, TIF, RAW and TGA!!\n"); return 1; } - if(!((parameters->outfile[0] == 0))){ + if(!(parameters->outfile[0] == 0)){ fprintf(stderr, "Error: options -ImgDir and -o cannot be used together !!\n"); return 1; } }else{ - if((parameters->infile[0] == 0) ) { + if( parameters->infile[0] == 0 ) { fprintf(stderr, "Example: %s -i image.j2k\n",argv[0]); fprintf(stderr, " Try: %s -h\n",argv[0]); return 1; diff --git a/applications/jpip/libopenjpip/byte_manager.c b/applications/jpip/libopenjpip/byte_manager.c index 4dd887bc..5ce80dda 100644 --- a/applications/jpip/libopenjpip/byte_manager.c +++ b/applications/jpip/libopenjpip/byte_manager.c @@ -76,13 +76,13 @@ Byte_t fetch_1byte( int fd, long offset) if( lseek( fd, offset, SEEK_SET)==-1){ fprintf( FCGI_stdout, "Reason: Target broken (seek error)\r\n"); - fprintf( FCGI_stderr, "Error: error in fetch_1byte( %d, %ld)\n", fd, offset); + fprintf( FCGI_stderr, "Error: error in fetch_1byte( %d, %lld)\n", fd, offset); return 0; } if( read( fd, &code, 1) != 1){ fprintf( FCGI_stdout, "Reason: Target broken (read error)\r\n"); - fprintf( FCGI_stderr, "Error: error in fetch_bytes( %d, %ld)\n", fd, offset); + fprintf( FCGI_stderr, "Error: error in fetch_bytes( %d, %lld)\n", fd, offset); return 0; } return code; @@ -94,7 +94,7 @@ Byte2_t fetch_2bytebigendian( int fd, long offset) Byte2_t code; if(!(data = fetch_bytes( fd, offset, 2))){ - fprintf( FCGI_stderr, "Error: error in fetch_2bytebigendian( %d, %ld)\n", fd, offset); + fprintf( FCGI_stderr, "Error: error in fetch_2bytebigendian( %d, %lld)\n", fd, offset); return 0; } code = big2(data); @@ -109,7 +109,7 @@ Byte4_t fetch_4bytebigendian( int fd, long offset) Byte4_t code; if(!(data = fetch_bytes( fd, offset, 4))){ - fprintf( FCGI_stderr, "Error: error in fetch_4bytebigendian( %d, %ld)\n", fd, offset); + fprintf( FCGI_stderr, "Error: error in fetch_4bytebigendian( %d, %lld)\n", fd, offset); return 0; } code = big4(data); @@ -124,7 +124,7 @@ Byte8_t fetch_8bytebigendian( int fd, long offset) Byte8_t code; if(!(data = fetch_bytes( fd, offset, 8))){ - fprintf( FCGI_stderr, "Error: error in fetch_8bytebigendian( %d, %ld)\n", fd, offset); + fprintf( FCGI_stderr, "Error: error in fetch_8bytebigendian( %d, %lld)\n", fd, offset); return 0; } code = big8(data); diff --git a/libopenjpeg/jpwl/jpwl_lib.c b/libopenjpeg/jpwl/jpwl_lib.c index 90a71cec..bb940112 100644 --- a/libopenjpeg/jpwl/jpwl_lib.c +++ b/libopenjpeg/jpwl/jpwl_lib.c @@ -677,7 +677,7 @@ opj_bool jpwl_correct(opj_j2k_t *j2k) { id = cio_read(cio, 2); /* details */ - printf("Marker@%d: %X\n", cio_tell(cio) - 2, id); + printf("Marker@%lld: %X\n", cio_tell(cio) - 2, id); /* do an action in response to the read marker */ switch (id) { diff --git a/libopenjpeg/tcd.c b/libopenjpeg/tcd.c index eb6237d7..ee052055 100644 --- a/libopenjpeg/tcd.c +++ b/libopenjpeg/tcd.c @@ -1418,13 +1418,15 @@ opj_bool tcd_decode_tile(opj_tcd_t *tcd, unsigned char *src, int len, int tileno int numres2decode; if (tcd->cp->reduce != 0) { - tcd->image->comps[compno].resno_decoded = - tile->comps[compno].numresolutions - tcd->cp->reduce - 1; - if (tcd->image->comps[compno].resno_decoded < 0) { + if ( tile->comps[compno].numresolutions < ( tcd->cp->reduce - 1 ) ) { opj_event_msg(tcd->cinfo, EVT_ERROR, "Error decoding tile. The number of resolutions to remove [%d+1] is higher than the number " " of resolutions in the original codestream [%d]\nModify the cp_reduce parameter.\n", tcd->cp->reduce, tile->comps[compno].numresolutions); return OPJ_FALSE; } + else { + tcd->image->comps[compno].resno_decoded = + tile->comps[compno].numresolutions - tcd->cp->reduce - 1; + } } numres2decode = tcd->image->comps[compno].resno_decoded + 1;