fix a few coverity issues
a couple of minor bugs, and a lot of warnings
This commit is contained in:
parent
3b75d90174
commit
d88dd1ab72
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,6 +1,7 @@
|
||||
a.out
|
||||
*.log
|
||||
*.trs
|
||||
cov-int
|
||||
tmp
|
||||
tmp-*
|
||||
test/variables.sh
|
||||
|
@ -424,7 +424,7 @@ vips__formatalike( VipsImage *in1, VipsImage *in2,
|
||||
in[0] = in1;
|
||||
in[1] = in2;
|
||||
|
||||
if( vips__formatalike_vec( in, out, 2 ) )
|
||||
if( vips__formatalike_vec( in, &out[0], 2 ) )
|
||||
return( -1 );
|
||||
|
||||
*out1 = out[0];
|
||||
@ -443,7 +443,7 @@ vips__sizealike( VipsImage *in1, VipsImage *in2,
|
||||
in[0] = in1;
|
||||
in[1] = in2;
|
||||
|
||||
if( vips__sizealike_vec( in, out, 2 ) )
|
||||
if( vips__sizealike_vec( in, &out[0], 2 ) )
|
||||
return( -1 );
|
||||
|
||||
*out1 = out[0];
|
||||
@ -462,7 +462,7 @@ vips__bandalike( const char *domain,
|
||||
in[0] = in1;
|
||||
in[1] = in2;
|
||||
|
||||
if( vips__bandalike_vec( domain, in, out, 2, 1 ) )
|
||||
if( vips__bandalike_vec( domain, in, &out[0], 2, 1 ) )
|
||||
return( -1 );
|
||||
|
||||
*out1 = out[0];
|
||||
|
@ -419,14 +419,12 @@ argb2rgba( uint32_t *buf, int n, uint32_t bg )
|
||||
uint8_t a = x >> 24;
|
||||
VipsPel *out = (VipsPel *) p;
|
||||
|
||||
if( a == 255 ) {
|
||||
*p = GUINT32_TO_BE((x << 8) | 255);
|
||||
}
|
||||
else if( a == 0 ) {
|
||||
if( a == 255 )
|
||||
*p = GUINT32_TO_BE( (x << 8) | 255 );
|
||||
else if( a == 0 )
|
||||
/* Use background color.
|
||||
*/
|
||||
*p = GUINT32_TO_BE((bg << 8) | 255);
|
||||
}
|
||||
*p = GUINT32_TO_BE( (bg << 8) | 255 );
|
||||
else {
|
||||
/* Undo premultiplication.
|
||||
*/
|
||||
|
@ -974,7 +974,7 @@ rad2vips_process_line( char *line, Read *read )
|
||||
read->aspect *= aspectval( line );
|
||||
}
|
||||
else if( isprims( line ) ) {
|
||||
primsval( read->prims, line );
|
||||
(void) primsval( read->prims, line );
|
||||
}
|
||||
|
||||
return( 0 );
|
||||
|
@ -1110,14 +1110,16 @@ parse_header( ReadTiff *rtiff, VipsImage *out )
|
||||
{
|
||||
uint16 v;
|
||||
|
||||
TIFFGetFieldDefaulted( rtiff->tiff, TIFFTAG_SAMPLEFORMAT, &v );
|
||||
rtiff->sample_format = SAMPLEFORMAT_INT;
|
||||
|
||||
/* Some images have this set to void, bizarre.
|
||||
*/
|
||||
if( v == SAMPLEFORMAT_VOID )
|
||||
v = SAMPLEFORMAT_UINT;
|
||||
if( TIFFGetFieldDefaulted( rtiff->tiff, TIFFTAG_SAMPLEFORMAT, &v ) ) {
|
||||
/* Some images have this set to void, bizarre.
|
||||
*/
|
||||
if( v == SAMPLEFORMAT_VOID )
|
||||
v = SAMPLEFORMAT_UINT;
|
||||
|
||||
rtiff->sample_format = v;
|
||||
rtiff->sample_format = v;
|
||||
}
|
||||
}
|
||||
|
||||
/* Arbitrary sanity-checking limits.
|
||||
|
@ -427,7 +427,7 @@ typedef void (*write_fn)( ExifData *ed,
|
||||
|
||||
/* Write a tag. Update what's there, or make a new one.
|
||||
*/
|
||||
static int
|
||||
static void
|
||||
write_tag( ExifData *ed, int ifd, ExifTag tag, write_fn fn, void *data )
|
||||
{
|
||||
ExifEntry *entry;
|
||||
@ -448,8 +448,6 @@ write_tag( ExifData *ed, int ifd, ExifTag tag, write_fn fn, void *data )
|
||||
|
||||
fn( ed, entry, 0, data );
|
||||
}
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
/* This is different, we set the xres/yres from the vips header rather than
|
||||
@ -501,16 +499,12 @@ set_exif_resolution( ExifData *ed, VipsImage *im )
|
||||
/* Main image xres/yres/unit are in ifd0. ifd1 has the thumbnail
|
||||
* xres/yres/unit.
|
||||
*/
|
||||
if( write_tag( ed, 0, EXIF_TAG_X_RESOLUTION,
|
||||
vips_exif_set_double, (void *) &xres ) ||
|
||||
write_tag( ed, 0, EXIF_TAG_Y_RESOLUTION,
|
||||
vips_exif_set_double, (void *) &yres ) ||
|
||||
write_tag( ed, 0, EXIF_TAG_RESOLUTION_UNIT,
|
||||
vips_exif_set_int, (void *) &unit ) ) {
|
||||
vips_error( "VipsJpeg",
|
||||
"%s", _( "error setting JPEG resolution" ) );
|
||||
return( -1 );
|
||||
}
|
||||
write_tag( ed, 0, EXIF_TAG_X_RESOLUTION,
|
||||
vips_exif_set_double, (void *) &xres );
|
||||
write_tag( ed, 0, EXIF_TAG_Y_RESOLUTION,
|
||||
vips_exif_set_double, (void *) &yres );
|
||||
write_tag( ed, 0, EXIF_TAG_RESOLUTION_UNIT,
|
||||
vips_exif_set_int, (void *) &unit );
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
@ -523,14 +517,10 @@ set_exif_dimensions( ExifData *ed, VipsImage *im )
|
||||
VIPS_DEBUG_MSG( "set_exif_dimensions: vips size of %d, %d\n",
|
||||
im->Xsize, im->Ysize );
|
||||
|
||||
if( write_tag( ed, 2, EXIF_TAG_PIXEL_X_DIMENSION,
|
||||
vips_exif_set_int, (void *) &im->Xsize ) ||
|
||||
write_tag( ed, 2, EXIF_TAG_PIXEL_Y_DIMENSION,
|
||||
vips_exif_set_int, (void *) &im->Ysize ) ) {
|
||||
vips_error( "VipsJpeg",
|
||||
"%s", _( "error setting JPEG dimensions" ) );
|
||||
return( -1 );
|
||||
}
|
||||
write_tag( ed, 2, EXIF_TAG_PIXEL_X_DIMENSION,
|
||||
vips_exif_set_int, (void *) &im->Xsize );
|
||||
write_tag( ed, 2, EXIF_TAG_PIXEL_Y_DIMENSION,
|
||||
vips_exif_set_int, (void *) &im->Ysize );
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
@ -1324,10 +1314,15 @@ term_destination( j_compress_ptr cinfo )
|
||||
*/
|
||||
if( !(obuf = vips_malloc( NULL, len )) )
|
||||
ERREXIT( cinfo, JERR_FILE_WRITE );
|
||||
*(buf->obuf) = obuf;
|
||||
*(buf->olen) = len;
|
||||
else {
|
||||
/* coverity doesn't know ERREXIT() does not return, so put
|
||||
* this in an else.
|
||||
*/
|
||||
*(buf->obuf) = obuf;
|
||||
*(buf->olen) = len;
|
||||
|
||||
block_copy( buf->block, obuf );
|
||||
block_copy( buf->block, obuf );
|
||||
}
|
||||
}
|
||||
|
||||
/* Set dest to one of our objects.
|
||||
|
@ -151,7 +151,7 @@ read_new( const char *filename, void *data, size_t length )
|
||||
*
|
||||
* mmap the input file, it's slightly quicker.
|
||||
*/
|
||||
if( !(read->fd = vips__open_image_read( read->filename )) ||
|
||||
if( (read->fd = vips__open_image_read( read->filename )) < 0 ||
|
||||
(read->length = vips_file_length( read->fd )) < 0 ||
|
||||
!(read->data = vips__mmap( read->fd,
|
||||
FALSE, read->length, 0 )) ) {
|
||||
|
@ -528,19 +528,19 @@ vips_buf_append_size( VipsBuf *buf, size_t n )
|
||||
*/
|
||||
N_( "bytes" ),
|
||||
|
||||
/* Kilo byte unit.
|
||||
/* Kilobyte unit.
|
||||
*/
|
||||
N_( "KB" ),
|
||||
|
||||
/* Mega byte unit.
|
||||
/* Megabyte unit.
|
||||
*/
|
||||
N_( "MB" ),
|
||||
|
||||
/* Giga byte unit.
|
||||
/* Gigabyte unit.
|
||||
*/
|
||||
N_( "GB" ),
|
||||
|
||||
/* Tera byte unit.
|
||||
/* Terabyte unit.
|
||||
*/
|
||||
N_( "TB" )
|
||||
};
|
||||
@ -548,14 +548,16 @@ vips_buf_append_size( VipsBuf *buf, size_t n )
|
||||
double sz = n;
|
||||
int i;
|
||||
|
||||
for( i = 0; sz > 1024 && i < VIPS_NUMBER( names ); sz /= 1024, i++ )
|
||||
/* -1, since we want to stop at TB, not run off the end.
|
||||
*/
|
||||
for( i = 0; sz > 1024 && i < VIPS_NUMBER( names ) - 1; sz /= 1024, i++ )
|
||||
;
|
||||
|
||||
if( i == 0 )
|
||||
/* No decimal places for bytes.
|
||||
*/
|
||||
return( vips_buf_appendf( buf, "%g %s", sz, _( names[i] ) ) );
|
||||
else
|
||||
else
|
||||
return( vips_buf_appendf( buf, "%.2f %s", sz, _( names[i] ) ) );
|
||||
}
|
||||
|
||||
|
@ -1503,30 +1503,29 @@ int
|
||||
vips_image_history_printf( VipsImage *image, const char *fmt, ... )
|
||||
{
|
||||
va_list args;
|
||||
char line[VIPS_PATH_MAX];
|
||||
char str[VIPS_PATH_MAX];
|
||||
VipsBuf buf = VIPS_BUF_STATIC( str );
|
||||
time_t timebuf;
|
||||
|
||||
/* Format command. -40, to leave 26 for the ctime, three for the # and
|
||||
* a bit.
|
||||
*/
|
||||
va_start( args, fmt );
|
||||
(void) vips_vsnprintf( line, VIPS_PATH_MAX - 40, fmt, args );
|
||||
(void) vips_buf_vappendf( &buf, fmt, args );
|
||||
va_end( args );
|
||||
strcat( line, " # " );
|
||||
vips_buf_appends( &buf, " # " );
|
||||
|
||||
/* Add the date. ctime always attaches a '\n', gah.
|
||||
*/
|
||||
time( &timebuf );
|
||||
strcat( line, ctime( &timebuf ) );
|
||||
line[strlen( line ) - 1] = '\0';
|
||||
vips_buf_appends( &buf, ctime( &timebuf ) );
|
||||
vips_buf_removec( &buf, '\n' );
|
||||
|
||||
#ifdef DEBUG
|
||||
printf( "vips_image_history_printf: "
|
||||
"adding:\n\t%s\nto history on image %p\n", line, image );
|
||||
"adding:\n\t%s\nto history on image %p\n",
|
||||
vips_buf_all( &buf ), image );
|
||||
#endif /*DEBUG*/
|
||||
|
||||
image->history_list = g_slist_append( image->history_list,
|
||||
vips__gvalue_ref_string_new( line ) );
|
||||
vips__gvalue_ref_string_new( vips_buf_all( &buf ) ) );
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
@ -363,7 +363,7 @@ vips_region_sanity( VipsObject *object, VipsBuf *buf )
|
||||
{
|
||||
VipsRegion *region = VIPS_REGION( object );
|
||||
|
||||
vips_object_sanity( VIPS_OBJECT( region->im ) );
|
||||
(void) vips_object_sanity( VIPS_OBJECT( region->im ) );
|
||||
|
||||
switch( region->im->dtype ) {
|
||||
case VIPS_IMAGE_PARTIAL:
|
||||
|
@ -1688,6 +1688,7 @@ vips__substitute( char *buf, size_t len, char *sub )
|
||||
n = atoi( p + 1 );
|
||||
if( lowest_n == -1 ||
|
||||
n < lowest_n ) {
|
||||
lowest_n = n;
|
||||
sub_start = p;
|
||||
sub_end = q + 1;
|
||||
}
|
||||
|
@ -74,9 +74,14 @@ im__initialize( TIE_POINTS *points )
|
||||
++j;
|
||||
}
|
||||
|
||||
xdelta = xdelta/j;
|
||||
ydelta = ydelta/j;
|
||||
for(i = 0; i < npt; i++ ) {
|
||||
if( j == 0 ) {
|
||||
vips_error( "im_initialize", "no tie points" );
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
xdelta = xdelta / j;
|
||||
ydelta = ydelta / j;
|
||||
for( i = 0; i < npt; i++ ) {
|
||||
dx[i] = (xsec[i] - xref[i]) - xdelta;
|
||||
dy[i] = (ysec[i] - yref[i]) - ydelta;
|
||||
}
|
||||
@ -84,7 +89,7 @@ im__initialize( TIE_POINTS *points )
|
||||
for( i = 0; i < npt; i++ ) {
|
||||
a1 = dx[i];
|
||||
a2 = dy[i];
|
||||
points->deviation[i] = sqrt( a1*a1 + a2*a2 );
|
||||
points->deviation[i] = sqrt( a1 * a1 + a2 * a2 );
|
||||
}
|
||||
|
||||
points->l_scale = 1.0;
|
||||
|
@ -430,6 +430,12 @@ vips_affine_build( VipsObject *object )
|
||||
"interpolate", interpolate,
|
||||
NULL );
|
||||
g_object_unref( interpolate );
|
||||
|
||||
/* coverity gets confused by this, it thinks
|
||||
* affine->interpolate may still be null. Assign ourselves,
|
||||
* even though we don't need to.
|
||||
*/
|
||||
affine->interpolate = interpolate;
|
||||
}
|
||||
|
||||
in = resample->in;
|
||||
@ -492,7 +498,7 @@ vips_affine_build( VipsObject *object )
|
||||
/* Check for coordinate overflow ... we want to be able to hold the
|
||||
* output space inside INT_MAX / TRANSFORM_SCALE.
|
||||
*/
|
||||
edge = INT_MAX / VIPS_TRANSFORM_SCALE;
|
||||
edge = (int) (INT_MAX / VIPS_TRANSFORM_SCALE);
|
||||
if( affine->trn.oarea.left < -edge ||
|
||||
affine->trn.oarea.top < -edge ||
|
||||
VIPS_RECT_RIGHT( &affine->trn.oarea ) > edge ||
|
||||
|
Loading…
Reference in New Issue
Block a user