small fixes for clang static analyzer

a few small things clang static analyzer found
This commit is contained in:
John Cupitt 2013-11-22 14:34:13 +00:00
parent 2f602eedd6
commit 5b7b3cb591
14 changed files with 35 additions and 29 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
scan
po/*.pot
test-driver
vips-*.tar.gz

View File

@ -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:

View File

@ -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];

View File

@ -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];

View File

@ -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 );
}

View File

@ -236,7 +236,6 @@ vips_rot45_build( VipsObject *object )
case VIPS_ANGLE45_45:
vips_rot45_rot45( t[0], from );
from = t[0];
break;
default:

View File

@ -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.

View File

@ -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 ) {

View File

@ -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 ) {

View File

@ -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",

View File

@ -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

View File

@ -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++ )

View File

@ -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 );
}

View File

@ -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 ) )