various tweaks to calm coverity

passes cleanly now
This commit is contained in:
John Cupitt 2017-01-20 08:55:13 +00:00
parent 0de517ed23
commit b140c18a37
8 changed files with 91 additions and 67 deletions

2
TODO
View File

@ -1,3 +1,5 @@
- seem to be leaking VipsReorder
- not sure about utf8 error messages on win
- strange:

View File

@ -770,19 +770,19 @@ operator+( VImage a, std::vector<double> b )
}
VImage &
operator+=( VImage a, const VImage b )
operator+=( VImage &a, const VImage b )
{
return( a = a + b );
}
VImage &
operator+=( VImage a, const double b )
operator+=( VImage &a, const double b )
{
return( a = a + b );
}
VImage &
operator+=( VImage a, std::vector<double> b )
operator+=( VImage &a, std::vector<double> b )
{
return( a = a + b );
}
@ -818,19 +818,19 @@ operator-( VImage a, std::vector<double> b )
}
VImage &
operator-=( VImage a, const VImage b )
operator-=( VImage &a, const VImage b )
{
return( a = a - b );
}
VImage &
operator-=( VImage a, const double b )
operator-=( VImage &a, const double b )
{
return( a = a - b );
}
VImage &
operator-=( VImage a, std::vector<double> b )
operator-=( VImage &a, std::vector<double> b )
{
return( a = a - b );
}
@ -872,19 +872,19 @@ operator*( VImage a, std::vector<double> b )
}
VImage &
operator*=( VImage a, const VImage b )
operator*=( VImage &a, const VImage b )
{
return( a = a * b );
}
VImage &
operator*=( VImage a, const double b )
operator*=( VImage &a, const double b )
{
return( a = a * b );
}
VImage &
operator*=( VImage a, std::vector<double> b )
operator*=( VImage &a, std::vector<double> b )
{
return( a = a * b );
}
@ -920,19 +920,19 @@ operator/( VImage a, std::vector<double> b )
}
VImage &
operator/=( VImage a, const VImage b )
operator/=( VImage &a, const VImage b )
{
return( a = a / b );
}
VImage &
operator/=( VImage a, const double b )
operator/=( VImage &a, const double b )
{
return( a = a / b );
}
VImage &
operator/=( VImage a, std::vector<double> b )
operator/=( VImage &a, std::vector<double> b )
{
return( a = a / b );
}
@ -956,19 +956,19 @@ operator%( VImage a, std::vector<double> b )
}
VImage &
operator%=( VImage a, const VImage b )
operator%=( VImage &a, const VImage b )
{
return( a = a % b );
}
VImage &
operator%=( VImage a, const double b )
operator%=( VImage &a, const double b )
{
return( a = a % b );
}
VImage &
operator%=( VImage a, std::vector<double> b )
operator%=( VImage &a, std::vector<double> b )
{
return( a = a % b );
}
@ -1210,19 +1210,19 @@ operator&( VImage a, std::vector<double> b )
}
VImage &
operator&=( VImage a, const VImage b )
operator&=( VImage &a, const VImage b )
{
return( a = a & b );
}
VImage &
operator&=( VImage a, const double b )
operator&=( VImage &a, const double b )
{
return( a = a & b );
}
VImage &
operator&=( VImage a, std::vector<double> b )
operator&=( VImage &a, std::vector<double> b )
{
return( a = a & b );
}
@ -1260,19 +1260,19 @@ operator|( VImage a, std::vector<double> b )
}
VImage &
operator|=( VImage a, const VImage b )
operator|=( VImage &a, const VImage b )
{
return( a = a | b );
}
VImage &
operator|=( VImage a, const double b )
operator|=( VImage &a, const double b )
{
return( a = a | b );
}
VImage &
operator|=( VImage a, std::vector<double> b )
operator|=( VImage &a, std::vector<double> b )
{
return( a = a | b );
}
@ -1310,19 +1310,19 @@ operator^( VImage a, std::vector<double> b )
}
VImage &
operator^=( VImage a, const VImage b )
operator^=( VImage &a, const VImage b )
{
return( a = a ^ b );
}
VImage &
operator^=( VImage a, const double b )
operator^=( VImage &a, const double b )
{
return( a = a ^ b );
}
VImage &
operator^=( VImage a, std::vector<double> b )
operator^=( VImage &a, std::vector<double> b )
{
return( a = a ^ b );
}
@ -1347,19 +1347,19 @@ operator<<( VImage a, std::vector<double> b )
}
VImage &
operator<<=( VImage a, const VImage b )
operator<<=( VImage &a, const VImage b )
{
return( a = a << b );
}
VImage &
operator<<=( VImage a, const double b )
operator<<=( VImage &a, const double b )
{
return( a = a << b );
}
VImage &
operator<<=( VImage a, std::vector<double> b )
operator<<=( VImage &a, std::vector<double> b )
{
return( a = a << b );
}
@ -1384,19 +1384,19 @@ operator>>( VImage a, std::vector<double> b )
}
VImage &
operator>>=( VImage a, const VImage b )
operator>>=( VImage &a, const VImage b )
{
return( a = a << b );
}
VImage &
operator>>=( VImage a, const double b )
operator>>=( VImage &a, const double b )
{
return( a = a << b );
}
VImage &
operator>>=( VImage a, std::vector<double> b )
operator>>=( VImage &a, std::vector<double> b )
{
return( a = a << b );
}

View File

@ -781,9 +781,9 @@ public:
friend VIPS_CPLUSPLUS_API VImage operator+( std::vector<double> a, VImage b );
friend VIPS_CPLUSPLUS_API VImage operator+( VImage a, std::vector<double> b );
friend VIPS_CPLUSPLUS_API VImage & operator+=( VImage a, const VImage b );
friend VIPS_CPLUSPLUS_API VImage & operator+=( VImage a, const double b );
friend VIPS_CPLUSPLUS_API VImage & operator+=( VImage a, const std::vector<double> b );
friend VIPS_CPLUSPLUS_API VImage & operator+=( VImage &a, const VImage b );
friend VIPS_CPLUSPLUS_API VImage & operator+=( VImage &a, const double b );
friend VIPS_CPLUSPLUS_API VImage & operator+=( VImage &a, const std::vector<double> b );
friend VIPS_CPLUSPLUS_API VImage operator-( VImage a, VImage b );
friend VIPS_CPLUSPLUS_API VImage operator-( double a, VImage b );
@ -791,9 +791,9 @@ public:
friend VIPS_CPLUSPLUS_API VImage operator-( std::vector<double> a, VImage b );
friend VIPS_CPLUSPLUS_API VImage operator-( VImage a, std::vector<double> b );
friend VIPS_CPLUSPLUS_API VImage & operator-=( VImage a, const VImage b );
friend VIPS_CPLUSPLUS_API VImage & operator-=( VImage a, const double b );
friend VIPS_CPLUSPLUS_API VImage & operator-=( VImage a, const std::vector<double> b );
friend VIPS_CPLUSPLUS_API VImage & operator-=( VImage &a, const VImage b );
friend VIPS_CPLUSPLUS_API VImage & operator-=( VImage &a, const double b );
friend VIPS_CPLUSPLUS_API VImage & operator-=( VImage &a, const std::vector<double> b );
friend VIPS_CPLUSPLUS_API VImage operator-( VImage a );
@ -803,9 +803,9 @@ public:
friend VIPS_CPLUSPLUS_API VImage operator*( std::vector<double> a, VImage b );
friend VIPS_CPLUSPLUS_API VImage operator*( VImage a, std::vector<double> b );
friend VIPS_CPLUSPLUS_API VImage & operator*=( VImage a, const VImage b );
friend VIPS_CPLUSPLUS_API VImage & operator*=( VImage a, const double b );
friend VIPS_CPLUSPLUS_API VImage & operator*=( VImage a, const std::vector<double> b );
friend VIPS_CPLUSPLUS_API VImage & operator*=( VImage &a, const VImage b );
friend VIPS_CPLUSPLUS_API VImage & operator*=( VImage &a, const double b );
friend VIPS_CPLUSPLUS_API VImage & operator*=( VImage &a, const std::vector<double> b );
friend VIPS_CPLUSPLUS_API VImage operator/( VImage a, VImage b );
friend VIPS_CPLUSPLUS_API VImage operator/( double a, VImage b );
@ -813,17 +813,17 @@ public:
friend VIPS_CPLUSPLUS_API VImage operator/( std::vector<double> a, VImage b );
friend VIPS_CPLUSPLUS_API VImage operator/( VImage a, std::vector<double> b );
friend VIPS_CPLUSPLUS_API VImage & operator/=( VImage a, const VImage b );
friend VIPS_CPLUSPLUS_API VImage & operator/=( VImage a, const double b );
friend VIPS_CPLUSPLUS_API VImage & operator/=( VImage a, const std::vector<double> b );
friend VIPS_CPLUSPLUS_API VImage & operator/=( VImage &a, const VImage b );
friend VIPS_CPLUSPLUS_API VImage & operator/=( VImage &a, const double b );
friend VIPS_CPLUSPLUS_API VImage & operator/=( VImage &a, const std::vector<double> b );
friend VIPS_CPLUSPLUS_API VImage operator%( VImage a, VImage b );
friend VIPS_CPLUSPLUS_API VImage operator%( VImage a, double b );
friend VIPS_CPLUSPLUS_API VImage operator%( VImage a, std::vector<double> b );
friend VIPS_CPLUSPLUS_API VImage & operator%=( VImage a, const VImage b );
friend VIPS_CPLUSPLUS_API VImage & operator%=( VImage a, const double b );
friend VIPS_CPLUSPLUS_API VImage & operator%=( VImage a, const std::vector<double> b );
friend VIPS_CPLUSPLUS_API VImage & operator%=( VImage &a, const VImage b );
friend VIPS_CPLUSPLUS_API VImage & operator%=( VImage &a, const double b );
friend VIPS_CPLUSPLUS_API VImage & operator%=( VImage &a, const std::vector<double> b );
friend VIPS_CPLUSPLUS_API VImage operator<( VImage a, VImage b );
friend VIPS_CPLUSPLUS_API VImage operator<( double a, VImage b );
@ -867,9 +867,9 @@ public:
friend VIPS_CPLUSPLUS_API VImage operator&( std::vector<double> a, VImage b );
friend VIPS_CPLUSPLUS_API VImage operator&( VImage a, std::vector<double> b );
friend VIPS_CPLUSPLUS_API VImage & operator&=( VImage a, const VImage b );
friend VIPS_CPLUSPLUS_API VImage & operator&=( VImage a, const double b );
friend VIPS_CPLUSPLUS_API VImage & operator&=( VImage a, const std::vector<double> b );
friend VIPS_CPLUSPLUS_API VImage & operator&=( VImage &a, const VImage b );
friend VIPS_CPLUSPLUS_API VImage & operator&=( VImage &a, const double b );
friend VIPS_CPLUSPLUS_API VImage & operator&=( VImage &a, const std::vector<double> b );
friend VIPS_CPLUSPLUS_API VImage operator|( VImage a, VImage b );
friend VIPS_CPLUSPLUS_API VImage operator|( double a, VImage b );
@ -877,9 +877,9 @@ public:
friend VIPS_CPLUSPLUS_API VImage operator|( std::vector<double> a, VImage b );
friend VIPS_CPLUSPLUS_API VImage operator|( VImage a, std::vector<double> b );
friend VIPS_CPLUSPLUS_API VImage & operator|=( VImage a, const VImage b );
friend VIPS_CPLUSPLUS_API VImage & operator|=( VImage a, const double b );
friend VIPS_CPLUSPLUS_API VImage & operator|=( VImage a, const std::vector<double> b );
friend VIPS_CPLUSPLUS_API VImage & operator|=( VImage &a, const VImage b );
friend VIPS_CPLUSPLUS_API VImage & operator|=( VImage &a, const double b );
friend VIPS_CPLUSPLUS_API VImage & operator|=( VImage &a, const std::vector<double> b );
friend VIPS_CPLUSPLUS_API VImage operator^( VImage a, VImage b );
friend VIPS_CPLUSPLUS_API VImage operator^( double a, VImage b );
@ -887,25 +887,25 @@ public:
friend VIPS_CPLUSPLUS_API VImage operator^( std::vector<double> a, VImage b );
friend VIPS_CPLUSPLUS_API VImage operator^( VImage a, std::vector<double> b );
friend VIPS_CPLUSPLUS_API VImage & operator^=( VImage a, const VImage b );
friend VIPS_CPLUSPLUS_API VImage & operator^=( VImage a, const double b );
friend VIPS_CPLUSPLUS_API VImage & operator^=( VImage a, const std::vector<double> b );
friend VIPS_CPLUSPLUS_API VImage & operator^=( VImage &a, const VImage b );
friend VIPS_CPLUSPLUS_API VImage & operator^=( VImage &a, const double b );
friend VIPS_CPLUSPLUS_API VImage & operator^=( VImage &a, const std::vector<double> b );
friend VIPS_CPLUSPLUS_API VImage operator<<( VImage a, VImage b );
friend VIPS_CPLUSPLUS_API VImage operator<<( VImage a, double b );
friend VIPS_CPLUSPLUS_API VImage operator<<( VImage a, std::vector<double> b );
friend VIPS_CPLUSPLUS_API VImage & operator<<=( VImage a, const VImage b );
friend VIPS_CPLUSPLUS_API VImage & operator<<=( VImage a, const double b );
friend VIPS_CPLUSPLUS_API VImage & operator<<=( VImage a, const std::vector<double> b );
friend VIPS_CPLUSPLUS_API VImage & operator<<=( VImage &a, const VImage b );
friend VIPS_CPLUSPLUS_API VImage & operator<<=( VImage &a, const double b );
friend VIPS_CPLUSPLUS_API VImage & operator<<=( VImage &a, const std::vector<double> b );
friend VIPS_CPLUSPLUS_API VImage operator>>( VImage a, VImage b );
friend VIPS_CPLUSPLUS_API VImage operator>>( VImage a, double b );
friend VIPS_CPLUSPLUS_API VImage operator>>( VImage a, std::vector<double> b );
friend VIPS_CPLUSPLUS_API VImage & operator>>=( VImage a, const VImage b );
friend VIPS_CPLUSPLUS_API VImage & operator>>=( VImage a, const double b );
friend VIPS_CPLUSPLUS_API VImage & operator>>=( VImage a, const std::vector<double> b );
friend VIPS_CPLUSPLUS_API VImage & operator>>=( VImage &a, const VImage b );
friend VIPS_CPLUSPLUS_API VImage & operator>>=( VImage &a, const double b );
friend VIPS_CPLUSPLUS_API VImage & operator>>=( VImage &a, const std::vector<double> b );
};

View File

@ -213,7 +213,8 @@ write_vips_property( VipsImage *image,
xmlNode *child;
g_value_init( &save_value, VIPS_TYPE_SAVE_STRING );
g_value_transform( value, &save_value );
if( !g_value_transform( value, &save_value ) )
return( image );
if( !(property = new_child( info, info->node, "property" )) )
return( image );

View File

@ -1167,7 +1167,7 @@ vips_image_map( VipsImage *image, VipsImageMapFn fn, void *a )
for( i = 0; i < VIPS_NUMBER( vips_header_fields ); i++ ) {
HeaderField *field = &vips_header_fields[i];
vips_image_get( image, field->name, &value );
(void) vips_image_get( image, field->name, &value );
result = fn( image, field->name, &value, a );
g_value_unset( &value );

View File

@ -159,6 +159,27 @@ vips_mapim_region_minmax( VipsRegion *region, VipsRect *r, VipsRect *bounds )
bounds->height = 1 + max_y - min_y;
}
#define ULOOKUP( TYPE ) { \
TYPE * restrict p1 = (TYPE *) p; \
\
for( x = 0; x < r->width; x++ ) { \
TYPE px = p1[0]; \
TYPE py = p1[1]; \
\
if( px >= resample->in->Xsize || \
py >= resample->in->Ysize ) { \
for( z = 0; z < ps; z++ ) \
q[z] = 0; \
} \
else \
interpolate( mapim->interpolate, q, ir[0], \
px + window_offset, py + window_offset ); \
\
p1 += 2; \
q += ps; \
} \
}
#define LOOKUP( TYPE ) { \
TYPE * restrict p1 = (TYPE *) p; \
\
@ -265,15 +286,15 @@ vips_mapim_gen( VipsRegion *or, void *seq, void *a, void *b, gboolean *stop )
switch( ir[1]->im->BandFmt ) {
case VIPS_FORMAT_UCHAR:
LOOKUP( unsigned char ); break;
ULOOKUP( unsigned char ); break;
case VIPS_FORMAT_CHAR:
LOOKUP( signed char ); break;
case VIPS_FORMAT_USHORT:
LOOKUP( unsigned short ); break;
ULOOKUP( unsigned short ); break;
case VIPS_FORMAT_SHORT:
LOOKUP( signed short ); break;
case VIPS_FORMAT_UINT:
LOOKUP( unsigned int ); break;
ULOOKUP( unsigned int ); break;
case VIPS_FORMAT_INT:
LOOKUP( signed int ); break;

View File

@ -283,7 +283,7 @@ vips_shrinkh_build( VipsObject *object )
* fractional part), we just see the integer part here.
*/
resample->out->Xsize = VIPS_ROUND_UINT(
resample->in->Xsize / shrink->hshrink );
(double) resample->in->Xsize / shrink->hshrink );
if( resample->out->Xsize <= 0 ) {
vips_error( class->nickname,
"%s", _( "image has shrunk to nothing" ) );

View File

@ -387,7 +387,7 @@ vips_shrinkv_build( VipsObject *object )
* fractional part), we just see the integer part here.
*/
resample->out->Ysize = VIPS_ROUND_UINT(
resample->in->Ysize / shrink->vshrink );
(double) resample->in->Ysize / shrink->vshrink );
if( resample->out->Ysize <= 0 ) {
vips_error( class->nickname,
"%s", _( "image has shrunk to nothing" ) );