fix some cppcheck warnings
This commit is contained in:
parent
147b135944
commit
8956ba536b
@ -37,6 +37,10 @@ Then for a debug build:
|
||||
$ make
|
||||
$ make install
|
||||
|
||||
Static analysis with:
|
||||
|
||||
$ cppcheck --force --enable=style . &> cppcheck.log
|
||||
|
||||
# Dependencies
|
||||
|
||||
libvips has to have gettext, glib-2.x and libxml-2.0. The build system needs
|
||||
|
@ -141,12 +141,11 @@ colr_color(col, clr) /* convert short to float color */
|
||||
register COLOR col;
|
||||
register COLR clr;
|
||||
{
|
||||
double f;
|
||||
|
||||
if (clr[EXP] == 0)
|
||||
col[RED] = col[GRN] = col[BLU] = 0.0;
|
||||
else {
|
||||
f = ldexp(1.0, (int)clr[EXP]-(COLXS+8));
|
||||
double f = ldexp(1.0, (int)clr[EXP]-(COLXS+8));
|
||||
|
||||
col[RED] = (clr[RED] + 0.5)*f;
|
||||
col[GRN] = (clr[GRN] + 0.5)*f;
|
||||
col[BLU] = (clr[BLU] + 0.5)*f;
|
||||
|
@ -284,13 +284,14 @@ static void
|
||||
vips_format_summary_class( VipsObjectClass *object_class, VipsBuf *buf )
|
||||
{
|
||||
VipsFormatClass *class = VIPS_FORMAT_CLASS( object_class );
|
||||
const char **p;
|
||||
|
||||
VIPS_OBJECT_CLASS( vips_format_parent_class )->
|
||||
summary_class( object_class, buf );
|
||||
vips_buf_appends( buf, ", " );
|
||||
|
||||
if( class->suffs ) {
|
||||
const char **p;
|
||||
|
||||
vips_buf_appends( buf, "(" );
|
||||
for( p = class->suffs; *p; p++ ) {
|
||||
vips_buf_appendf( buf, "%s", *p );
|
||||
|
@ -774,14 +774,16 @@ im_map_packages( VSListMap2Fn fn, void *a )
|
||||
{
|
||||
void *r = im_slist_map2( plugin_list,
|
||||
(VSListMap2Fn) apply_plugin, (void *) fn, a );
|
||||
int i;
|
||||
|
||||
/* If not there, try main VIPS package list.
|
||||
*/
|
||||
if( !r )
|
||||
if( !r ) {
|
||||
int i;
|
||||
|
||||
for( i = 0; i < VIPS_NUMBER( built_in ); i++ )
|
||||
if( (r = fn( built_in[i], a, NULL )) )
|
||||
return( r );
|
||||
}
|
||||
|
||||
return( r );
|
||||
}
|
||||
@ -1089,8 +1091,6 @@ add_hist( im_function *fn, im_object *vargv, int argc, char **argv )
|
||||
static int
|
||||
dispatch_function( im_function *fn, im_object *vargv, int argc, char **argv )
|
||||
{
|
||||
int i;
|
||||
|
||||
/* Init memory from command line arguments.
|
||||
*/
|
||||
if( build_args( fn, vargv, argc, argv ) )
|
||||
@ -1107,7 +1107,9 @@ dispatch_function( im_function *fn, im_object *vargv, int argc, char **argv )
|
||||
* - create a region on the input, closed by a
|
||||
* close callback on the output image
|
||||
*/
|
||||
if( fn->flags & IM_FN_PIO )
|
||||
if( fn->flags & IM_FN_PIO ) {
|
||||
int i;
|
||||
|
||||
for( i = 0; i < fn->argc; i++ ) {
|
||||
im_type_desc *type = fn->argv[i].desc;
|
||||
|
||||
@ -1116,6 +1118,7 @@ dispatch_function( im_function *fn, im_object *vargv, int argc, char **argv )
|
||||
if( note_dependencies( fn, vargv, i ) )
|
||||
return( -1 );
|
||||
}
|
||||
}
|
||||
|
||||
/* Call function.
|
||||
*/
|
||||
|
@ -317,13 +317,13 @@ vips_wrap7_object_set_property( GObject *gobject,
|
||||
vips__argument_table_lookup( oclass->argument_table, pspec );
|
||||
VipsArgumentInstance *argument_instance =
|
||||
vips__argument_get_instance( argument_class, object );
|
||||
|
||||
VipsWrap7 *wrap7 = VIPS_WRAP7( gobject );
|
||||
VipsWrap7Class *class = VIPS_WRAP7_GET_CLASS( wrap7 );
|
||||
int i = argument_class->offset;
|
||||
im_arg_desc *arg = &class->fn->argv[i];
|
||||
im_type_desc *type = arg->desc;
|
||||
im_arg_type vt = type->type;
|
||||
|
||||
int i;
|
||||
im_arg_desc *arg;
|
||||
im_type_desc *type;
|
||||
im_arg_type vt;
|
||||
|
||||
g_assert( argument_instance );
|
||||
|
||||
@ -333,6 +333,11 @@ vips_wrap7_object_set_property( GObject *gobject,
|
||||
return;
|
||||
}
|
||||
|
||||
i = argument_class->offset;
|
||||
arg = &class->fn->argv[i];
|
||||
type = arg->desc;
|
||||
vt = type->type;
|
||||
|
||||
#ifdef DEBUG
|
||||
{
|
||||
char *str_value;
|
||||
@ -418,13 +423,13 @@ vips_wrap7_object_get_property( GObject *gobject,
|
||||
vips__argument_table_lookup( class->argument_table, pspec );
|
||||
VipsArgumentInstance *argument_instance =
|
||||
vips__argument_get_instance( argument_class, object );
|
||||
|
||||
VipsWrap7 *wrap7 = VIPS_WRAP7( gobject );
|
||||
VipsWrap7Class *wclass = VIPS_WRAP7_GET_CLASS( wrap7 );
|
||||
int i = argument_class->offset;
|
||||
im_arg_desc *arg = &wclass->fn->argv[i];
|
||||
im_type_desc *type = arg->desc;
|
||||
im_arg_type vt = type->type;
|
||||
|
||||
int i;
|
||||
im_arg_desc *arg;
|
||||
im_type_desc *type;
|
||||
im_arg_type vt;
|
||||
|
||||
if( !argument_class ) {
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID( gobject,
|
||||
@ -432,6 +437,11 @@ vips_wrap7_object_get_property( GObject *gobject,
|
||||
return;
|
||||
}
|
||||
|
||||
i = argument_class->offset;
|
||||
arg = &wclass->fn->argv[i];
|
||||
type = arg->desc;
|
||||
vt = type->type;
|
||||
|
||||
g_assert( ((VipsArgument *) argument_class)->pspec == pspec );
|
||||
|
||||
if( !argument_instance->assigned ) {
|
||||
|
@ -172,7 +172,7 @@ read_double( FILE *fp, const char whitemap[256], const char sepmap[256],
|
||||
|
||||
if( ch == '"' ) {
|
||||
(void) fgetc( fp );
|
||||
ch = skip_to_quote( fp );
|
||||
(void) skip_to_quote( fp );
|
||||
ch = fgetc( fp );
|
||||
}
|
||||
else if( !sepmap[ch] &&
|
||||
|
@ -1161,8 +1161,7 @@ vips_foreign_save_dz_build( VipsObject *object )
|
||||
vips_area_unref( background );
|
||||
}
|
||||
|
||||
if( dz->overlap >= dz->tile_size ||
|
||||
dz->overlap >= dz->tile_size ) {
|
||||
if( dz->overlap >= dz->tile_size ) {
|
||||
vips_error( "dzsave",
|
||||
"%s", _( "overlap must be less than tile "
|
||||
"width and height" ) ) ;
|
||||
|
@ -355,13 +355,14 @@ static void
|
||||
vips_foreign_summary_class( VipsObjectClass *object_class, VipsBuf *buf )
|
||||
{
|
||||
VipsForeignClass *class = VIPS_FOREIGN_CLASS( object_class );
|
||||
const char **p;
|
||||
|
||||
VIPS_OBJECT_CLASS( vips_foreign_parent_class )->
|
||||
summary_class( object_class, buf );
|
||||
vips_buf_appends( buf, " " );
|
||||
|
||||
if( class->suffs ) {
|
||||
const char **p;
|
||||
|
||||
vips_buf_appends( buf, "(" );
|
||||
for( p = class->suffs; *p; p++ ) {
|
||||
vips_buf_appendf( buf, "%s", *p );
|
||||
|
@ -104,11 +104,12 @@ int
|
||||
vips__openslide_isslide( const char *filename )
|
||||
{
|
||||
openslide_t *osr;
|
||||
const char *vendor;
|
||||
int ok;
|
||||
|
||||
ok = 0;
|
||||
if( (osr = openslide_open( filename )) ) {
|
||||
const char *vendor;
|
||||
|
||||
/* Generic tiled tiff images can be opened by openslide as
|
||||
* well. Only offer to load this file if it's not a generic
|
||||
* tiff since we want vips_tiffload() to handle these.
|
||||
@ -278,9 +279,7 @@ int
|
||||
vips__openslide_read_header( const char *filename, VipsImage *out,
|
||||
int level, char *associated )
|
||||
{
|
||||
ReadSlide *rslide;
|
||||
|
||||
if( !(rslide = readslide_new( filename, out, level, associated )) )
|
||||
if( !readslide_new( filename, out, level, associated ) )
|
||||
return( -1 );
|
||||
|
||||
return( 0 );
|
||||
|
@ -81,9 +81,7 @@
|
||||
static void
|
||||
skip_line( FILE *fp )
|
||||
{
|
||||
int ch;
|
||||
|
||||
while( (ch = fgetc( fp )) != '\n' )
|
||||
while( fgetc( fp ) != '\n' )
|
||||
;
|
||||
}
|
||||
|
||||
|
@ -89,11 +89,12 @@ compare( const void *a, const void *b )
|
||||
static void
|
||||
free_state( State *state )
|
||||
{
|
||||
if( state->data ) {
|
||||
int i;
|
||||
|
||||
if( state->data )
|
||||
for( i = 0; i < state->input->ysize; i++ )
|
||||
IM_FREE( state->data[i] );
|
||||
}
|
||||
|
||||
IM_FREE( state->data );
|
||||
IM_FREE( state->buf );
|
||||
|
@ -80,21 +80,18 @@ normalise( IMAGE *in, IMAGE *out )
|
||||
return( -1 );
|
||||
}
|
||||
else if( vips_bandfmt_isint( in->BandFmt ) ) {
|
||||
IMAGE *t1;
|
||||
double min;
|
||||
|
||||
/* Move min up to 0.
|
||||
*/
|
||||
if( !(t1 = im_open_local( out, "im_histplot", "p" )) ||
|
||||
im_min( in, &min ) ||
|
||||
im_lintra( 1.0, in, -min, t1 ) )
|
||||
if( im_min( in, &min ) ||
|
||||
im_lintra( 1.0, in, -min, out ) )
|
||||
return( -1 );
|
||||
}
|
||||
else {
|
||||
/* Float image: scale min--max to 0--any. Output square
|
||||
* graph.
|
||||
*/
|
||||
IMAGE *t1;
|
||||
DOUBLEMASK *stats;
|
||||
double min, max;
|
||||
int any;
|
||||
@ -110,8 +107,7 @@ normalise( IMAGE *in, IMAGE *out )
|
||||
max = VIPS_MASK( stats, 1, 0 );
|
||||
im_free_dmask( stats );
|
||||
|
||||
if( !(t1 = im_open_local( out, "im_histplot", "p" )) ||
|
||||
im_lintra( any / (max - min), in,
|
||||
if( im_lintra( any / (max - min), in,
|
||||
-min * any / (max - min), out ) )
|
||||
return( -1 );
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ encode24( char *p, int bits, size_t remaining )
|
||||
int i;
|
||||
|
||||
for( i = 0; i < 4; i++ ) {
|
||||
if( remaining <= 0 )
|
||||
if( remaining == 0 )
|
||||
p[i] = '=';
|
||||
else {
|
||||
/* Take the top 6 bits of 24.
|
||||
@ -165,7 +165,7 @@ vips__b64_encode( const unsigned char *data, size_t data_length )
|
||||
size_t i;
|
||||
int cursor;
|
||||
|
||||
if( data_length <= 0 ) {
|
||||
if( data_length == 0 ) {
|
||||
vips_error( "vips__b64_encode", "%s", _( "too little data" ) );
|
||||
return( NULL );
|
||||
}
|
||||
@ -209,7 +209,7 @@ vips__b64_encode( const unsigned char *data, size_t data_length )
|
||||
for( total = 0, i = 0; i < data_length; i++ )
|
||||
total += data[i];
|
||||
|
||||
printf( "vips__b64_encode: length = %d, checksum 0x%x\n",
|
||||
printf( "vips__b64_encode: length = %u, checksum 0x%x\n",
|
||||
data_length, total & 0xffff );
|
||||
}
|
||||
#endif /*DEBUG*/
|
||||
|
@ -509,13 +509,12 @@ vips_allocate_input_array( VipsImage *image, ... )
|
||||
{
|
||||
va_list ap;
|
||||
VipsImage **ar;
|
||||
VipsImage *im;
|
||||
int i, n;
|
||||
|
||||
/* Count input images.
|
||||
*/
|
||||
va_start( ap, image );
|
||||
for( n = 0; (im = va_arg( ap, VipsImage * )); n++ )
|
||||
for( n = 0; va_arg( ap, VipsImage * ); n++ )
|
||||
;
|
||||
va_end( ap );
|
||||
|
||||
|
@ -468,7 +468,8 @@ vips_image_sanity( VipsObject *object, VipsBuf *buf )
|
||||
image->dtype > VIPS_IMAGE_PARTIAL ||
|
||||
image->dhint > VIPS_DEMAND_STYLE_ANY )
|
||||
vips_buf_appends( buf, "bad enum\n" );
|
||||
if( image->Xres < 0 || image->Xres < 0 )
|
||||
if( image->Xres < 0 ||
|
||||
image->Yres < 0 )
|
||||
vips_buf_appends( buf, "bad resolution\n" );
|
||||
}
|
||||
|
||||
|
@ -230,10 +230,11 @@ vips_tracked_free( void *s )
|
||||
if( vips_tracked_allocs <= 0 )
|
||||
vips_warn( "vips_tracked",
|
||||
"%s", _( "vips_free: too many frees" ) );
|
||||
vips_tracked_mem -= size;
|
||||
if( vips_tracked_mem < 0 )
|
||||
if( vips_tracked_mem < size )
|
||||
vips_warn( "vips_tracked",
|
||||
"%s", _( "vips_free: too much free" ) );
|
||||
|
||||
vips_tracked_mem -= size;
|
||||
vips_tracked_allocs -= 1;
|
||||
|
||||
g_mutex_unlock( vips_tracked_mutex );
|
||||
|
@ -848,7 +848,6 @@ static void
|
||||
tile_copy( Tile *tile, VipsRegion *to )
|
||||
{
|
||||
VipsRect ovlap;
|
||||
int y;
|
||||
|
||||
/* Find common pixels.
|
||||
*/
|
||||
@ -861,6 +860,8 @@ tile_copy( Tile *tile, VipsRegion *to )
|
||||
if( tile->painted && !tile->region->invalid ) {
|
||||
int len = VIPS_IMAGE_SIZEOF_PEL( to->im ) * ovlap.width;
|
||||
|
||||
int y;
|
||||
|
||||
VIPS_DEBUG_MSG( "tile_copy: "
|
||||
"copying calculated pixels for %p %dx%d\n",
|
||||
tile, tile->area.left, tile->area.top );
|
||||
|
@ -791,12 +791,16 @@ vips__file_read( FILE *fp, const char *filename, unsigned int *length_out )
|
||||
len = 0;
|
||||
size = 0;
|
||||
do {
|
||||
char *str2;
|
||||
|
||||
size += 1024;
|
||||
if( !(str = realloc( str, size )) ) {
|
||||
if( !(str2 = realloc( str, size )) ) {
|
||||
free( str );
|
||||
vips_error( "vips__file_read",
|
||||
"%s", _( "out of memory" ) );
|
||||
return( NULL );
|
||||
}
|
||||
str = str2;
|
||||
|
||||
/* -1 to allow space for an extra NULL we add later.
|
||||
*/
|
||||
@ -1601,7 +1605,7 @@ vips__parse_size( const char *size_string )
|
||||
|
||||
guint64 size;
|
||||
int n;
|
||||
int i, j;
|
||||
int i;
|
||||
char *unit;
|
||||
|
||||
/* An easy way to alloc a buffer large enough.
|
||||
@ -1610,6 +1614,8 @@ vips__parse_size( const char *size_string )
|
||||
n = sscanf( size_string, "%d %s", &i, unit );
|
||||
size = i;
|
||||
if( n > 1 ) {
|
||||
int j;
|
||||
|
||||
for( j = 0; j < VIPS_NUMBER( units ); j++ )
|
||||
if( tolower( unit[0] ) == units[j].unit ) {
|
||||
size *= units[j].multiplier;
|
||||
|
@ -80,7 +80,7 @@ im_profile( IMAGE *in, IMAGE *out, int dir )
|
||||
{
|
||||
int sz;
|
||||
unsigned short *buf;
|
||||
int x, y, b;
|
||||
int x, y;
|
||||
|
||||
/* If in is not uchar, do (!=0) to make a uchar image.
|
||||
*/
|
||||
@ -149,6 +149,8 @@ im_profile( IMAGE *in, IMAGE *out, int dir )
|
||||
for( y = 0; y < in->Ysize; y++ ) {
|
||||
VipsPel *p = IM_IMAGE_ADDR( in, 0, y );
|
||||
|
||||
int b;
|
||||
|
||||
for( b = 0; b < in->Bands; b++ ) {
|
||||
VipsPel *p1;
|
||||
|
||||
|
@ -104,11 +104,12 @@ rank_stop( void *vseq, void *a, void *b )
|
||||
RankSequence *seq = (RankSequence *) vseq;
|
||||
Rank *rank = (Rank *) b;
|
||||
|
||||
if( seq->ir ) {
|
||||
int i;
|
||||
|
||||
if( seq->ir )
|
||||
for( i = 0; i < rank->n; i++ )
|
||||
IM_FREEF( im_region_free, seq->ir[i] );
|
||||
}
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
@ -712,7 +712,6 @@ static JoinNode *
|
||||
find_root( SymbolTable *st )
|
||||
{
|
||||
JoinNode *root;
|
||||
JoinNode *notroot;
|
||||
|
||||
/* Clean the table, then scan it, setting all pointed-to nodes dirty.
|
||||
*/
|
||||
@ -736,7 +735,7 @@ find_root( SymbolTable *st )
|
||||
* more than one root.
|
||||
*/
|
||||
root->dirty = 1;
|
||||
if( (notroot = im__map_table( st, is_root, NULL, NULL )) ) {
|
||||
if( im__map_table( st, is_root, NULL, NULL ) ) {
|
||||
im_error( "im_global_balance",
|
||||
"%s", _( "more than one root" ) );
|
||||
return( NULL );
|
||||
|
Loading…
Reference in New Issue
Block a user