diff options
| author | Mathieu Malaterre <mathieu.malaterre@gmail.com> | 2012-03-26 15:56:04 +0000 |
|---|---|---|
| committer | Mathieu Malaterre <mathieu.malaterre@gmail.com> | 2012-03-26 15:56:04 +0000 |
| commit | 91ee6ed60f0f820ed0f6983000f10225cc60b217 (patch) | |
| tree | fc3adb1023de9f5a7a911870f68a7092f4c27d7b | |
| parent | 7e28fdc1761388d4cafae840612ac402891be83d (diff) | |
[trunk] change char* to const char* when possible. Remove more warnings
| -rw-r--r-- | applications/jpip/libopenjpip/cache_manager.c | 22 | ||||
| -rw-r--r-- | applications/jpip/libopenjpip/cache_manager.h | 14 | ||||
| -rw-r--r-- | applications/jpip/libopenjpip/imgreg_manager.c | 2 | ||||
| -rw-r--r-- | applications/jpip/libopenjpip/jp2k_encoder.c | 32 | ||||
| -rw-r--r-- | applications/jpip/libopenjpip/msgqueue_manager.c | 1 | ||||
| -rw-r--r-- | applications/jpip/libopenjpip/target_manager.c | 6 |
6 files changed, 44 insertions, 33 deletions
diff --git a/applications/jpip/libopenjpip/cache_manager.c b/applications/jpip/libopenjpip/cache_manager.c index e62730db..76f7b7b3 100644 --- a/applications/jpip/libopenjpip/cache_manager.c +++ b/applications/jpip/libopenjpip/cache_manager.c @@ -58,7 +58,7 @@ void delete_cachelist(cachelist_param_t **cachelist) free( *cachelist); } -cache_param_t * gene_cache( char *targetname, int csn, char *tid, char *cid) +cache_param_t * gene_cache( const char *targetname, int csn, char *tid, char *cid) { cache_param_t *cache; @@ -106,7 +106,7 @@ void insert_cache_into_list( cache_param_t *cache, cachelist_param_t *cachelist) cachelist->last = cache; } -cache_param_t * search_cache( char targetname[], cachelist_param_t *cachelist) +cache_param_t * search_cache( const char targetname[], cachelist_param_t *cachelist) { cache_param_t *foundcache; @@ -140,7 +140,7 @@ cache_param_t * search_cacheBycsn( int csn, cachelist_param_t *cachelist) return NULL; } -cache_param_t * search_cacheBycid( char cid[], cachelist_param_t *cachelist) +cache_param_t * search_cacheBycid( const char cid[], cachelist_param_t *cachelist) { cache_param_t *foundcache; int i; @@ -159,7 +159,7 @@ cache_param_t * search_cacheBycid( char cid[], cachelist_param_t *cachelist) return NULL; } -cache_param_t * search_cacheBytid( char tid[], cachelist_param_t *cachelist) +cache_param_t * search_cacheBytid( const char tid[], cachelist_param_t *cachelist) { cache_param_t *foundcache; @@ -176,12 +176,12 @@ cache_param_t * search_cacheBytid( char tid[], cachelist_param_t *cachelist) return NULL; } -void add_cachecid( char *cid, cache_param_t *cache) +void add_cachecid( const char *cid, cache_param_t *cache) { if( !cid) return; - if( (cache->cid = realloc( cache->cid, (cache->numOfcid+1)*sizeof(char *))) == NULL){ + if( (cache->cid = realloc( cache->cid, (OPJ_SIZE_T)(cache->numOfcid+1)*sizeof(char *))) == NULL){ fprintf( stderr, "failed to add new cid to cache table in add_cachecid()\n"); return; } @@ -191,7 +191,7 @@ void add_cachecid( char *cid, cache_param_t *cache) cache->numOfcid ++; } -void update_cachetid( char *tid, cache_param_t *cache) +void update_cachetid( const char *tid, cache_param_t *cache) { if( !tid) return; @@ -203,9 +203,9 @@ void update_cachetid( char *tid, cache_param_t *cache) } } -void remove_cidInCache( char *cid, cache_param_t *cache); +void remove_cidInCache( const char *cid, cache_param_t *cache); -void remove_cachecid( char *cid, cachelist_param_t *cachelist) +void remove_cachecid( const char *cid, cachelist_param_t *cachelist) { cache_param_t *cache; @@ -213,7 +213,7 @@ void remove_cachecid( char *cid, cachelist_param_t *cachelist) remove_cidInCache( cid, cache); } -void remove_cidInCache( char *cid, cache_param_t *cache) +void remove_cidInCache( const char *cid, cache_param_t *cache) { int idx = -1; char **tmp; @@ -232,7 +232,7 @@ void remove_cidInCache( char *cid, cache_param_t *cache) tmp = cache->cid; - cache->cid = (char **)malloc( (cache->numOfcid-1)*sizeof(char *)); + cache->cid = (char **)malloc( (OPJ_SIZE_T)(cache->numOfcid-1)*sizeof(char *)); for( i=0, j=0; i<cache->numOfcid; i++){ if( i != idx){ diff --git a/applications/jpip/libopenjpip/cache_manager.h b/applications/jpip/libopenjpip/cache_manager.h index 0b768600..0c9afb0b 100644 --- a/applications/jpip/libopenjpip/cache_manager.h +++ b/applications/jpip/libopenjpip/cache_manager.h @@ -76,7 +76,7 @@ void delete_cachelist(cachelist_param_t **cachelist); * @param[in] cid channel identifier * @return pointer to the generated cache */ -cache_param_t * gene_cache( char *targetname, int csn, char *tid, char *cid); +cache_param_t * gene_cache( const char *targetname, int csn, char *tid, char *cid); /** * delete a cache @@ -101,7 +101,7 @@ void insert_cache_into_list( cache_param_t *cache, cachelist_param_t *cachelist) * @param[in] cachelist cache list pointer * @return found cache pointer */ -cache_param_t * search_cache( char targetname[], cachelist_param_t *cachelist); +cache_param_t * search_cache( const char targetname[], cachelist_param_t *cachelist); /** @@ -121,7 +121,7 @@ cache_param_t * search_cacheBycsn( int csn, cachelist_param_t *cachelist); * @param[in] cachelist cache list pointer * @return found cache pointer */ -cache_param_t * search_cacheBycid( char cid[], cachelist_param_t *cachelist); +cache_param_t * search_cacheBycid( const char cid[], cachelist_param_t *cachelist); /** @@ -131,7 +131,7 @@ cache_param_t * search_cacheBycid( char cid[], cachelist_param_t *cachelist); * @param[in] cachelist cache list pointer * @return found cache pointer */ -cache_param_t * search_cacheBytid( char tid[], cachelist_param_t *cachelist); +cache_param_t * search_cacheBytid( const char tid[], cachelist_param_t *cachelist); /** * add cid into a cache @@ -139,7 +139,7 @@ cache_param_t * search_cacheBytid( char tid[], cachelist_param_t *cachelist); * @param[in] cid channel identifier * @param[in] cache cache pointer */ -void add_cachecid( char *cid, cache_param_t *cache); +void add_cachecid( const char *cid, cache_param_t *cache); /** @@ -148,7 +148,7 @@ void add_cachecid( char *cid, cache_param_t *cache); * @param[in] tid target identifier * @param[in] cache cache pointer */ -void update_cachetid( char *tid, cache_param_t *cache); +void update_cachetid( const char *tid, cache_param_t *cache); /** @@ -157,7 +157,7 @@ void update_cachetid( char *tid, cache_param_t *cache); * @param[in] cid channel identifier * @param[in] cachelist cachelist pointer */ -void remove_cachecid( char *cid, cachelist_param_t *cachelist); +void remove_cachecid( const char *cid, cachelist_param_t *cachelist); /** diff --git a/applications/jpip/libopenjpip/imgreg_manager.c b/applications/jpip/libopenjpip/imgreg_manager.c index ada6302b..3a713c32 100644 --- a/applications/jpip/libopenjpip/imgreg_manager.c +++ b/applications/jpip/libopenjpip/imgreg_manager.c @@ -31,6 +31,7 @@ #include <stdio.h> #include <math.h> #include <stdlib.h> +#include <assert.h> #include "imgreg_manager.h" #ifdef SERVER @@ -138,6 +139,7 @@ int comp_decomplev( int fw, int fh, int Xsiz, int Ysiz) find_level( 1000, &level, &fw, &fh, &xmin, &ymin, &xmax, &ymax); + assert( level >= 0 ); return level; } diff --git a/applications/jpip/libopenjpip/jp2k_encoder.c b/applications/jpip/libopenjpip/jp2k_encoder.c index 4f1b4143..23c8b2fe 100644 --- a/applications/jpip/libopenjpip/jp2k_encoder.c +++ b/applications/jpip/libopenjpip/jp2k_encoder.c @@ -33,6 +33,7 @@ #include <stdlib.h> #include <string.h> #include <math.h> +#include <assert.h> #include "jp2k_encoder.h" #include "j2kheader_manager.h" #include "imgreg_manager.h" @@ -102,7 +103,7 @@ Byte_t * recons_jp2( msgqueue_param_t *msgqueue, Byte_t *jpipstream, Byte8_t csn return NULL; ptr = msgqueue->first; - while(( ptr = search_message( METADATA_MSG, -1, csn, ptr))!=NULL){ + while(( ptr = search_message( METADATA_MSG, (Byte8_t)-1, csn, ptr))!=NULL){ if( ptr->phld){ if( strncmp( (char *)ptr->phld->OrigBH+4, "jp2c", 4) == 0){ jp2cDBoxOffset = *jp2len + ptr->phld->OrigBHlen; @@ -174,7 +175,7 @@ Byte_t * recons_codestream_from_JPTstream( msgqueue_param_t *msgqueue, Byte_t *j Byte8_t binOffset; message_param_t *ptr; SIZmarker_param_t SIZ; - int mindeclev; + OPJ_SIZE_T mindeclev; *j2klen = 0; j2kstream = add_mainhead_msgstream( msgqueue, jpipstream, j2kstream, csn, j2klen); @@ -185,7 +186,7 @@ Byte_t * recons_codestream_from_JPTstream( msgqueue_param_t *msgqueue, Byte_t *j if( fw <= 0 || fh <= 0) mindeclev = 0; else - mindeclev = comp_decomplev( fw, fh, SIZ.Xsiz, SIZ.Ysiz); + mindeclev = (OPJ_SIZE_T)comp_decomplev( fw, fh, (int)SIZ.Xsiz, (int)SIZ.Ysiz); last_tileID = get_last_tileID( msgqueue, csn, false); @@ -249,7 +250,7 @@ Byte_t * recons_codestream_from_JPPstream( msgqueue_param_t *msgqueue, Byte_t *j if( fw == 0 || fh == 0) mindeclev = 0; else - mindeclev = comp_decomplev( fw, fh, SIZ.Xsiz, SIZ.Ysiz); + mindeclev = comp_decomplev( fw, fh, (int)SIZ.Xsiz, (int)SIZ.Ysiz); max_reslev = -1; last_tileID = get_last_tileID( msgqueue, csn, true); @@ -298,7 +299,7 @@ Byte_t * add_mainhead_msgstream( msgqueue_param_t *msgqueue, Byte_t *origstream, ptr = msgqueue->first; binOffset = 0; - while(( ptr = search_message( MAINHEADER_MSG, -1, csn, ptr))!=NULL){ + while(( ptr = search_message( MAINHEADER_MSG, (Byte8_t)-1, csn, ptr))!=NULL){ if( ptr->bin_offset == binOffset){ j2kstream = add_msgstream( ptr, origstream, j2kstream, j2klen); binOffset += ptr->length; @@ -506,12 +507,15 @@ Byte_t * recons_CPRLbitstream( msgqueue_param_t *msgqueue, Byte_t *jpipstream, B int comp_numOfprcts( Byte8_t tileID, SIZmarker_param_t SIZ, CODmarker_param_t COD, int r) { + int ret; Byte4_t XTsiz, YTsiz; - XTsiz = get_tile_XSiz( SIZ, tileID, COD.numOfdecomp-r); - YTsiz = get_tile_YSiz( SIZ, tileID, COD.numOfdecomp-r); + XTsiz = get_tile_XSiz( SIZ, (Byte4_t)tileID, COD.numOfdecomp-r); + YTsiz = get_tile_YSiz( SIZ, (Byte4_t)tileID, COD.numOfdecomp-r); - return ceil((double)XTsiz/(double)COD.XPsiz[r])*ceil((double)YTsiz/(double)COD.YPsiz[r]); + ret = (int)(ceil((double)XTsiz/(double)COD.XPsiz[r])*ceil((double)YTsiz/(double)COD.YPsiz[r])); + assert( ret >= 0 ); + return ret; } Byte_t * add_padding( Byte8_t padding, Byte_t *j2kstream, Byte8_t *j2klen); @@ -526,7 +530,7 @@ Byte_t * recons_packet( msgqueue_param_t *msgqueue, Byte_t *jpipstream, Byte_t * int l; seqID = comp_seqID( tileID, SIZ, COD, res_idx, prct_idx); - precID = comp_precinct_id( tileID, comp_idx, seqID, SIZ.Csiz, SIZ.XTnum*SIZ.YTnum); + precID = comp_precinct_id( (int)tileID, comp_idx, (int)seqID, (int)SIZ.Csiz, (int)SIZ.XTnum*(int)SIZ.YTnum); ptr = msgqueue->first; binOffset = 0; @@ -563,7 +567,7 @@ Byte_t * recons_precinct( msgqueue_param_t *msgqueue, Byte_t *jpipstream, Byte_t message_param_t *ptr; bool foundPrec; - precID = comp_precinct_id( tileID, comp_idx, seqID, SIZ.Csiz, SIZ.XTnum*SIZ.YTnum); + precID = comp_precinct_id( (int)tileID, comp_idx, (int)seqID, (int)SIZ.Csiz, (int)SIZ.XTnum*(int)SIZ.YTnum); ptr = msgqueue->first; binOffset = 0; @@ -593,11 +597,13 @@ Byte8_t comp_seqID( Byte8_t tileID, SIZmarker_param_t SIZ, CODmarker_param_t COD { Byte8_t seqID = 0; int rr; + assert( p >= 0); + assert( r >= 0); for( rr=0; rr<r; rr++) - seqID += comp_numOfprcts( tileID, SIZ, COD, rr); + seqID += (Byte8_t)comp_numOfprcts( tileID, SIZ, COD, rr); - seqID += p; + seqID += (Byte8_t)p; return seqID; } @@ -778,7 +784,7 @@ Byte_t * gene_emptytilestream( const Byte8_t tileID, Byte8_t *length) *length = 14; buf = (Byte_t *)malloc(*length); - Isot = (((Byte2_t)tileID) << 8) | ((((Byte2_t)tileID) & 0xf0) >> 8); + Isot = (Byte2_t)((((Byte2_t)tileID) << 8) | ((((Byte2_t)tileID) & 0xf0) >> 8)); memcpy( buf, &SOT, 2); memcpy( buf+2, &Lsot, 2); diff --git a/applications/jpip/libopenjpip/msgqueue_manager.c b/applications/jpip/libopenjpip/msgqueue_manager.c index 83e576c9..e0855cca 100644 --- a/applications/jpip/libopenjpip/msgqueue_manager.c +++ b/applications/jpip/libopenjpip/msgqueue_manager.c @@ -281,6 +281,7 @@ void enqueue_precinct( int seq_id, int tile_id, int comp_id, int layers, msgqueu } } +/* MM FIXME: each params is coded on int, this is really not clear from the specs what it should be */ Byte8_t comp_precinct_id( int t, int c, int s, int num_components, int num_tiles) { return t + (c + s * num_components ) * num_tiles; diff --git a/applications/jpip/libopenjpip/target_manager.c b/applications/jpip/libopenjpip/target_manager.c index c62972b3..6f97aee6 100644 --- a/applications/jpip/libopenjpip/target_manager.c +++ b/applications/jpip/libopenjpip/target_manager.c @@ -31,6 +31,7 @@ #include <stdlib.h> #include <string.h> #include <stdio.h> +#include <assert.h> #ifdef _WIN32 #define snprintf _snprintf /* Visual Studio */ #include <io.h> @@ -336,8 +337,9 @@ int open_remotefile( char filepath[], char tmpfname[]) static size_t write_data(void *ptr, size_t size, size_t nmemb, void *stream) { int *fd = (int *)stream; - int written = write( *fd, ptr, size*nmemb); + ssize_t written = write( *fd, ptr, size*nmemb); + assert( written >= 0 ); - return written; + return (size_t)written; } #endif /*SERVER*/ |
