From 67a45a3749500fe29c63a2323c498f97b03308d2 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Wed, 30 Sep 2015 11:11:11 +0100 Subject: [PATCH] more small coverity tweaks --- libvips/arithmetic/linear.c | 9 +++++---- libvips/arithmetic/measure.c | 3 ++- libvips/arithmetic/stats.c | 2 +- libvips/colour/UCS2LCh.c | 8 ++++---- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/libvips/arithmetic/linear.c b/libvips/arithmetic/linear.c index b1b73ac3..321f7dc5 100644 --- a/libvips/arithmetic/linear.c +++ b/libvips/arithmetic/linear.c @@ -122,11 +122,8 @@ vips_linear_build( VipsObject *object ) VipsUnary *unary = (VipsUnary *) object; VipsLinear *linear = (VipsLinear *) object; - int bands; int i; - vips_image_decode_predict( unary->in, &bands, NULL ); - /* If we have a three-element vector we need to bandup the image to * match. */ @@ -135,8 +132,12 @@ vips_linear_build( VipsObject *object ) linear->n = VIPS_MAX( linear->n, linear->a->n ); if( linear->b ) linear->n = VIPS_MAX( linear->n, linear->b->n ); - if( unary->in ) + if( unary->in ) { + int bands; + + vips_image_decode_predict( unary->in, &bands, NULL ); linear->n = VIPS_MAX( linear->n, bands ); + } arithmetic->base_bands = linear->n; if( unary->in && diff --git a/libvips/arithmetic/measure.c b/libvips/arithmetic/measure.c index 906bc525..9497799c 100644 --- a/libvips/arithmetic/measure.c +++ b/libvips/arithmetic/measure.c @@ -104,7 +104,8 @@ vips_measure_build( VipsObject *object ) if( VIPS_OBJECT_CLASS( vips_measure_parent_class )->build( object ) ) return( -1 ); - vips_image_decode( measure->in, &ready ); + if( vips_image_decode( measure->in, &ready ) ) + return( -1 ); vips_object_local( measure, ready ); bands = vips_image_get_bands( ready ); diff --git a/libvips/arithmetic/stats.c b/libvips/arithmetic/stats.c index c011a7ac..c2d12466 100644 --- a/libvips/arithmetic/stats.c +++ b/libvips/arithmetic/stats.c @@ -113,7 +113,7 @@ vips_stats_build( VipsObject *object ) double *row0, *row; int b, y, i; - if( statistic->in ) { + if( vips_object_argument_isset( object, "in" ) ) int bands = vips_image_get_bands( statistic->in ); if( vips_check_noncomplex( class->nickname, statistic->in ) ) diff --git a/libvips/colour/UCS2LCh.c b/libvips/colour/UCS2LCh.c index 8426ebbe..2d807e35 100644 --- a/libvips/colour/UCS2LCh.c +++ b/libvips/colour/UCS2LCh.c @@ -151,7 +151,7 @@ vips_col_Lcmc2L( float Lcmc ) int known; known = floor( Lcmc * 10.0 ); - known = VIPS_CLIP( 0, known, 1000 ); + known = VIPS_CLIP( 0, known, 999 ); return( LI[known] + (LI[known + 1] - LI[known]) * (Lcmc * 10.0 - known) ); @@ -173,7 +173,7 @@ vips_col_Ccmc2C( float Ccmc ) int known; known = floor( Ccmc * 10.0 ); - known = VIPS_CLIP( 0, known, 3000 ); + known = VIPS_CLIP( 0, known, 2999 ); return( CI[known] + (CI[known + 1] - CI[known]) * (Ccmc * 10.0 - known) ); @@ -199,10 +199,10 @@ vips_col_Chcmc2h( float C, float hcmc ) /* Which row of the table? */ r = (int) ((C + 1.0) / 2.0); - r = VIPS_CLIP( 0, r, 100 ); + r = VIPS_CLIP( 0, r, 99 ); known = floor( hcmc ); - known = VIPS_CLIP( 0, known, 360 ); + known = VIPS_CLIP( 0, known, 359 ); return( hI[r][known] + (hI[r][(known + 1) % 360] - hI[r][known]) * (hcmc - known) );