Skip to content

Commit

Permalink
fix a few small things
Browse files Browse the repository at this point in the history
found with clang static analyzer
  • Loading branch information
jcupitt committed Mar 25, 2017
1 parent edf513c commit cf93828
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -112,7 +112,7 @@ Clang build:

Clang static analysis:

$ scan-build ./configure --disable-introspection
$ scan-build ./configure --disable-introspection --disable-debug
$ scan-build -o scan -v make
$ scan-view scan/2013-11-22-2

Expand Down
5 changes: 5 additions & 0 deletions libvips/colour/LCh2Lab.c
Expand Up @@ -102,6 +102,11 @@ vips_col_Ch2ab( float C, float h, float *a, float *b )
float out[3];
float *x;

/* could be anything, we don't use this value, but we must supply one
* or static analyzers will complain.
*/
in[0] = 50.0;

in[1] = C;
in[2] = h;
x = &in[0];
Expand Down
2 changes: 2 additions & 0 deletions libvips/conversion/smartcrop.c
Expand Up @@ -286,6 +286,8 @@ vips_smartcrop_build( VipsObject *object )

switch( smartcrop->interesting ) {
case VIPS_INTERESTING_NONE:
left = 0;
top = 0;
break;

case VIPS_INTERESTING_CENTRE:
Expand Down
13 changes: 8 additions & 5 deletions libvips/convolution/convi.c
Expand Up @@ -932,6 +932,10 @@ vips_convi_build( VipsObject *object )
return( -1 );
in = t[0];

/* Default to the C path.
*/
generate = vips_convi_gen;

/* For uchar input, try to make a vector path.
*/
if( vips_vector_isenabled() &&
Expand All @@ -946,9 +950,11 @@ vips_convi_build( VipsObject *object )
vips_convi_compile_free( convi );
}

/* If there's no vector path, fall back to C.
/* Make the data for the C path.
*/
if( !convi->n_pass ) {
if( generate == vips_convi_gen ) {
g_info( "using C path" );

/* Make an int version of our mask.
*/
if( vips__image_intize( M, &t[1] ) )
Expand Down Expand Up @@ -977,9 +983,6 @@ vips_convi_build( VipsObject *object )
convi->coeff_pos[0] = 0;
convi->nnz = 1;
}

generate = vips_convi_gen;
g_info( "using C path" );
}

g_object_set( convi, "out", vips_image_new(), NULL );
Expand Down
4 changes: 2 additions & 2 deletions libvips/convolution/convsep.c
Expand Up @@ -76,7 +76,7 @@ vips_convsep_build( VipsObject *object )
in = convolution->in;

if( convsep->precision == VIPS_PRECISION_APPROXIMATE ) {
if( vips_convasep( convolution->in, &t[0], convolution->M,
if( vips_convasep( in, &t[0], convolution->M,
"layers", convsep->layers,
NULL ) )
return( -1 );
Expand All @@ -90,7 +90,7 @@ vips_convsep_build( VipsObject *object )
*/
vips_image_set_double( t[0], "offset", 0 );

if( vips_conv( convolution->in, &t[1], convolution->M,
if( vips_conv( in, &t[1], convolution->M,
"precision", convsep->precision,
"layers", convsep->layers,
"cluster", convsep->cluster,
Expand Down
5 changes: 5 additions & 0 deletions libvips/foreign/tiff2vips.c
Expand Up @@ -1462,6 +1462,11 @@ rtiff_fill_region( VipsRegion *out, void *seq, void *a, void *b, gboolean *stop
while( y < r->height ) {
VipsRect tile, page, hit;

/* Not necessary, but it stops static analyzers complaining
* about a used-before-set.
*/
tile.height = 0;

x = 0;
while( x < r->width ) {
int page_no = rtiff->page + (r->top + y) /
Expand Down
1 change: 1 addition & 0 deletions libvips/iofuncs/buffer.c
Expand Up @@ -507,6 +507,7 @@ vips_buffer_new( VipsImage *im, VipsRect *area )
g_assert( buffer->cache );

buffer->ref_count = 1;
buffer->done = FALSE;
buffer->cache = NULL;
}
else {
Expand Down

0 comments on commit cf93828

Please sign in to comment.