diff --git a/.gitignore b/.gitignore index 03ef54ad..8cf92bc5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +scan po/*.pot test-driver vips-*.tar.gz diff --git a/README.md b/README.md index 23b1b752..9f9939fe 100644 --- a/README.md +++ b/README.md @@ -56,8 +56,9 @@ Clang build: Clang static analysis: - $ CC=... scan-build ./configure ... + $ scan-build ./configure --disable-introspection $ scan-build -o scan -v make + $ scan-view scan/2013-11-22-2 Clang dynamic analysis: diff --git a/libvips/colour/LCh2Lab.c b/libvips/colour/LCh2Lab.c index 7e646fd9..fc932667 100644 --- a/libvips/colour/LCh2Lab.c +++ b/libvips/colour/LCh2Lab.c @@ -62,11 +62,13 @@ G_DEFINE_TYPE( VipsLCh2Lab, vips_LCh2Lab, VIPS_TYPE_COLOUR_SPACE ); static void vips_LCh2Lab_line( VipsColour *colour, VipsPel *out, VipsPel **in, int width ) { - float *p = (float *) in[0]; - float *q = (float *) out; - + float *p; + float *q; int x; + p = (float *) in[0]; + q = (float *) out; + for( x = 0; x < width; x++ ) { float L = p[0]; float C = p[1]; @@ -81,6 +83,7 @@ vips_LCh2Lab_line( VipsColour *colour, VipsPel *out, VipsPel **in, int width ) q[0] = L; q[1] = a; q[2] = b; + q += 3; } } @@ -103,7 +106,7 @@ vips_col_Ch2ab( float C, float h, float *a, float *b ) in[1] = C; in[2] = h; - x = in; + x = &in[0]; vips_LCh2Lab_line( NULL, (VipsPel *) out, (VipsPel **) &x, 1 ); *a = out[1]; *b = out[2]; diff --git a/libvips/colour/Lab2LCh.c b/libvips/colour/Lab2LCh.c index 74228147..1c844052 100644 --- a/libvips/colour/Lab2LCh.c +++ b/libvips/colour/Lab2LCh.c @@ -98,11 +98,13 @@ vips_col_ab2Ch( float a, float b, float *C, float *h ) static void vips_Lab2LCh_line( VipsColour *colour, VipsPel *out, VipsPel **in, int width ) { - float *p = (float *) in[0]; - float *q = (float *) out; - + float *p; + float *q; int x; + p = (float *) in[0]; + q = (float *) out; + for( x = 0; x < width; x++ ) { float L = p[0]; float a = p[1]; diff --git a/libvips/conversion/cast.c b/libvips/conversion/cast.c index be048d0c..9ff69072 100644 --- a/libvips/conversion/cast.c +++ b/libvips/conversion/cast.c @@ -172,7 +172,7 @@ vips_cast_start( VipsImage *out, void *a, void *b ) seq->underflow = 0; if( !seq->ir ) { - vips_cast_stop( seq, NULL, NULL ); + vips_cast_stop( seq, a, b ); return( NULL ); } diff --git a/libvips/conversion/rot45.c b/libvips/conversion/rot45.c index b6cfe2c4..283a4ec5 100644 --- a/libvips/conversion/rot45.c +++ b/libvips/conversion/rot45.c @@ -236,7 +236,6 @@ vips_rot45_build( VipsObject *object ) case VIPS_ANGLE45_45: vips_rot45_rot45( t[0], from ); - from = t[0]; break; default: diff --git a/libvips/foreign/csv.c b/libvips/foreign/csv.c index 75a85c6f..dfee788b 100644 --- a/libvips/foreign/csv.c +++ b/libvips/foreign/csv.c @@ -183,7 +183,7 @@ read_double( FILE *fp, const char whitemap[256], const char sepmap[256], if( ch == '"' ) { (void) fgetc( fp ); (void) skip_to_quote( fp ); - ch = fgetc( fp ); + (void) fgetc( fp ); } else if( !sepmap[ch] && fscanf( fp, "%lf", out ) != 1 ) { @@ -196,7 +196,7 @@ read_double( FILE *fp, const char whitemap[256], const char sepmap[256], /* Step over the bad data to the next separator. */ - ch = skip_to_sep( fp, sepmap ); + (void) skip_to_sep( fp, sepmap ); } /* Don't need to check result, we have read a field successfully. diff --git a/libvips/foreign/fits.c b/libvips/foreign/fits.c index ac0e4a9c..4a0a56e7 100644 --- a/libvips/foreign/fits.c +++ b/libvips/foreign/fits.c @@ -225,7 +225,6 @@ vips_fits_get_header( VipsFits *fits, VipsImage *out ) VIPS_DEBUG_MSG( "%d) %lld\n", i, fits->naxes[i] ); #endif /*VIPS_DEBUG*/ - width = 1; height = 1; bands = 1; switch( fits->naxis ) { diff --git a/libvips/foreign/matlab.c b/libvips/foreign/matlab.c index 36e497a0..ff0e9198 100644 --- a/libvips/foreign/matlab.c +++ b/libvips/foreign/matlab.c @@ -157,7 +157,6 @@ mat2vips_get_header( matvar_t *var, VipsImage *im ) VipsInterpretation interpretation; int i; - width = 1; height = 1; bands = 1; switch( var->rank ) { diff --git a/libvips/foreign/tiff2vips.c b/libvips/foreign/tiff2vips.c index bd139538..04dfa92e 100644 --- a/libvips/foreign/tiff2vips.c +++ b/libvips/foreign/tiff2vips.c @@ -1424,8 +1424,11 @@ read_stripwise( ReadTiff *rtiff, VipsImage *out ) /* rows_per_strip can be 2 ** 32 - 1, meaning the whole image. Clip * this down to ysize to avoid confusing vips. + * + * And it musn't be zero. */ - rtiff->rows_per_strip = VIPS_MIN( rtiff->rows_per_strip, t[0]->Ysize ); + rtiff->rows_per_strip = + VIPS_CLIP( 1, rtiff->rows_per_strip, t[0]->Ysize ); #ifdef DEBUG printf( "read_stripwise: rows_per_strip = %u\n", diff --git a/libvips/foreign/vips2tiff.c b/libvips/foreign/vips2tiff.c index 0b0f2e80..73081cda 100644 --- a/libvips/foreign/vips2tiff.c +++ b/libvips/foreign/vips2tiff.c @@ -1190,7 +1190,7 @@ write_tif_stripwise( TiffWrite *tw ) static void delete_files( TiffWrite *tw ) { - PyramidLayer *layer = tw->layer; + PyramidLayer *layer; if( tw->bname ) { #ifndef DEBUG diff --git a/libvips/histogram/hist_local.c b/libvips/histogram/hist_local.c index 41365738..c9ee1b06 100644 --- a/libvips/histogram/hist_local.c +++ b/libvips/histogram/hist_local.c @@ -93,7 +93,8 @@ vips_hist_local_stop( void *vseq, void *a, void *b ) VipsImage *in = (VipsImage *) a; VIPS_UNREF( seq->ir ); - if( seq->hist ) { + if( seq->hist && + in ) { int i; for( i = 0; i < in->Bands; i++ ) diff --git a/libvips/inplace/flood.c b/libvips/inplace/flood.c index 2f84a0a6..30d3a896 100644 --- a/libvips/inplace/flood.c +++ b/libvips/inplace/flood.c @@ -127,10 +127,9 @@ typedef struct { static Buffer * buffer_build( void ) { - Buffer *buf = IM_NEW( NULL, Buffer ); + Buffer *buf; - if( !buf ) - return( NULL ); + buf = g_new( Buffer, 1 ); buf->next = NULL; buf->n = 0; @@ -146,7 +145,7 @@ buffer_free( Buffer *buf ) Buffer *p; p = buf->next; - im_free( buf ); + g_free( buf ); buf = p; } } @@ -175,8 +174,7 @@ buffer_add( Buffer *buf, Flood *flood, int x1, int x2, int y, int dir ) if( buf->n == PBUFSIZE ) { Buffer *new; - if( !(new = buffer_build()) ) - return( NULL ); + new = buffer_build(); new->next = buf; buf = new; } @@ -382,13 +380,10 @@ flood_new( IMAGE *image, IMAGE *test, int x, int y, VipsPel *ink, Rect *dout ) flood->top = y; flood->right = x; flood->bottom = y; + flood->in = buffer_build(); + flood->out = buffer_build(); - flood->in = NULL; - flood->out = NULL; - - if( !(flood->edge = (VipsPel *) im_malloc( NULL, flood->tsize )) || - !(flood->in = buffer_build()) || - !(flood->out = buffer_build()) ) { + if( !(flood->edge = (VipsPel *) im_malloc( NULL, flood->tsize )) ) { flood_free( flood ); return( NULL ); } diff --git a/libvips/iofuncs/operation.c b/libvips/iofuncs/operation.c index 6deb4db0..ade8ed0f 100644 --- a/libvips/iofuncs/operation.c +++ b/libvips/iofuncs/operation.c @@ -555,6 +555,9 @@ vips_call_required_optional( VipsOperation **operation, va_end( a ); va_end( b ); + if( result ) + return( -1 ); + /* Build from cache. */ if( vips_cache_operation_buildp( operation ) )