Merge remote-tracking branch 'origin/master' into gate

This commit is contained in:
John Cupitt 2013-11-25 08:55:41 +00:00
commit d49eed6d20
32 changed files with 122 additions and 67 deletions

1
.gitignore vendored
View File

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

View File

@ -50,6 +50,30 @@ Leak check:
--leak-check=yes \
vips ... > vips-vg.log 2>&1
Clang build:
$ CC=clang CXX=clang++ ./configure --prefix=/home/john/vips
Clang static analysis:
$ scan-build ./configure --disable-introspection
$ scan-build -o scan -v make
$ scan-view scan/2013-11-22-2
Clang dynamic analysis:
$ CC=clang CXX=clang++ LD=clang \
CFLAGS="-O1 -fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls" \
CXXFLAGS="-O1 -fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls" \
LDFLAGS=-fsanitize=address \
./configure --prefix=/home/john/vips --disable-introspection
$ CC=clang CXX=clang++ LD=clang \
CFLAGS="-g -O1 -fsanitize=thread -fPIC -pie -fno-omit-frame-pointer -fno-optimize-sibling-calls" \
CXXFLAGS="-g -O1 -fsanitize=thread -fPIC -pie -fno-omit-frame-pointer -fno-optimize-sibling-calls" \
LDFLAGS="-fsanitize=thread -fPIC -pie" \
./configure --prefix=/home/john/vips --disable-introspection
# Dependencies
libvips has to have gettext, glib-2.x and libxml-2.0. The build system needs

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

@ -635,7 +635,7 @@ vips_icc_export_build( VipsObject *object )
if( !vips_object_argument_isset( object, "pcs" ) &&
code->in &&
code->in->Type == VIPS_INTERPRETATION_XYZ )
icc->pcs = VIPS_INTERPRETATION_XYZ;
icc->pcs = VIPS_PCS_XYZ;
if( icc->pcs == VIPS_PCS_LAB ) {
#ifdef HAVE_LCMS2

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

@ -104,6 +104,7 @@ vips_convolution_class_init( VipsConvolutionClass *class )
{
GObjectClass *gobject_class = G_OBJECT_CLASS( class );
VipsObjectClass *vobject_class = VIPS_OBJECT_CLASS( class );
VipsOperationClass *operation_class = VIPS_OPERATION_CLASS( class );
gobject_class->set_property = vips_object_set_property;
gobject_class->get_property = vips_object_get_property;
@ -112,6 +113,8 @@ vips_convolution_class_init( VipsConvolutionClass *class )
vobject_class->description = _( "convolution operations" );
vobject_class->build = vips_convolution_build;
operation_class->flags = VIPS_OPERATION_SEQUENTIAL;
/* Inputs set by subclassess.
*/

View File

@ -131,6 +131,7 @@ vips_correlation_class_init( VipsCorrelationClass *class )
{
GObjectClass *gobject_class = G_OBJECT_CLASS( class );
VipsObjectClass *object_class = (VipsObjectClass *) class;
VipsOperationClass *operation_class = VIPS_OPERATION_CLASS( class );
gobject_class->set_property = vips_object_set_property;
gobject_class->get_property = vips_object_get_property;
@ -139,6 +140,8 @@ vips_correlation_class_init( VipsCorrelationClass *class )
object_class->description = _( "correlation operation" );
object_class->build = vips_correlation_build;
operation_class->flags = VIPS_OPERATION_SEQUENTIAL;
VIPS_ARG_IMAGE( class, "in", 0,
_( "Input" ),
_( "Input image argument" ),

View File

@ -102,6 +102,7 @@ vips_gaussblur_class_init( VipsGaussblurClass *class )
{
GObjectClass *gobject_class = G_OBJECT_CLASS( class );
VipsObjectClass *object_class = (VipsObjectClass *) class;
VipsOperationClass *operation_class = VIPS_OPERATION_CLASS( class );
gobject_class->set_property = vips_object_set_property;
gobject_class->get_property = vips_object_get_property;
@ -110,6 +111,8 @@ vips_gaussblur_class_init( VipsGaussblurClass *class )
object_class->description = _( "Unsharp masking for print" );
object_class->build = vips_gaussblur_build;
operation_class->flags = VIPS_OPERATION_SEQUENTIAL;
VIPS_ARG_IMAGE( class, "in", 1,
_( "Input" ),
_( "Input image" ),

View File

@ -295,6 +295,7 @@ vips_sharpen_class_init( VipsSharpenClass *class )
{
GObjectClass *gobject_class = G_OBJECT_CLASS( class );
VipsObjectClass *object_class = (VipsObjectClass *) class;
VipsOperationClass *operation_class = VIPS_OPERATION_CLASS( class );
gobject_class->set_property = vips_object_set_property;
gobject_class->get_property = vips_object_get_property;
@ -303,6 +304,8 @@ vips_sharpen_class_init( VipsSharpenClass *class )
object_class->description = _( "Unsharp masking for print" );
object_class->build = vips_sharpen_build;
operation_class->flags = VIPS_OPERATION_SEQUENTIAL;
VIPS_ARG_IMAGE( class, "in", 1,
_( "Input" ),
_( "Input image" ),

View File

@ -48,7 +48,8 @@
static VipsFormatFlags
analyze_flags( const char *filename )
{
return( vips_foreign_flags( "analyzeload", filename ) );
return( (VipsFormatFlags)
vips_foreign_flags( "analyzeload", filename ) );
}
static int

View File

@ -74,7 +74,8 @@ exr_flags( const char *name )
im_filename_split( name, filename, mode );
return( vips_foreign_flags( "openexrload", filename ) );
return( (VipsFormatFlags)
vips_foreign_flags( "openexrload", filename ) );
}
static int

View File

@ -110,7 +110,8 @@ openslide_flags( const char *name )
im_filename_split( name, filename, mode );
return( vips_foreign_flags( "openslideload", filename ) );
return( (VipsFormatFlags)
vips_foreign_flags( "openslideload", filename ) );
}
static int

View File

@ -63,7 +63,8 @@ isppm( const char *filename )
static VipsFormatFlags
ppm_flags( const char *filename )
{
return( vips_foreign_flags( "ppmload", filename ) );
return( (VipsFormatFlags)
vips_foreign_flags( "ppmload", filename ) );
}
static const char *ppm_suffs[] = { ".ppm", ".pgm", ".pbm", ".pfm", NULL };

View File

@ -132,7 +132,8 @@ tiff_flags( const char *name )
im_filename_split( name, filename, mode );
return( vips_foreign_flags( "tiffload", filename ) );
return( (VipsFormatFlags)
vips_foreign_flags( "tiffload", filename ) );
}
static int

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

@ -67,7 +67,7 @@ G_DEFINE_TYPE( VipsForeignLoadPpm, vips_foreign_load_ppm,
static VipsForeignFlags
vips_foreign_load_ppm_get_flags_filename( const char *filename )
{
return( vips__ppm_flags( filename ) );
return( (VipsForeignFlags) vips__ppm_flags( filename ) );
}
static VipsForeignFlags

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

@ -186,7 +186,7 @@ read_image( Read *read, VipsImage *out )
{
VipsImage **t = (VipsImage **)
vips_object_local_array( VIPS_OBJECT( out ), 3 );
guint64 length;
gint64 length;
void *data;
int fd;
webp_decoder decoder;

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

@ -86,12 +86,15 @@ void *vips_foreign_map( const char *base,
VipsSListMap2Fn fn, void *a, void *b );
/* Image file load properties.
*
* Keep in sync with the deprecated VipsFormatFlags, we need to be able to
* cast between them.
*/
typedef enum /*< flags >*/ {
VIPS_FOREIGN_NONE = 0, /* No flags set */
VIPS_FOREIGN_PARTIAL = 1, /* Lazy read OK (eg. tiled tiff) */
VIPS_FOREIGN_SEQUENTIAL = 2, /* Top-to-bottom lazy read OK */
VIPS_FOREIGN_BIGENDIAN = 4, /* Most-significant byte first */
VIPS_FOREIGN_BIGENDIAN = 2, /* Most-significant byte first */
VIPS_FOREIGN_SEQUENTIAL = 4, /* Top-to-bottom lazy read OK */
VIPS_FOREIGN_ALL = 7 /* All flags set */
} VipsForeignFlags;

View File

@ -235,7 +235,7 @@ typedef struct _VipsImage {
* file start. Usually VIPS_SIZEOF_HEADER, but can be something else
* for binary file read.
*
* gint64 so that we can guarantee to work even on systems with
* guint64 so that we can guarantee to work even on systems with
* strange ideas about large files.
*/
guint64 sizeof_header;

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

@ -14,8 +14,8 @@ vips_foreign_flags_get_type( void )
static const GFlagsValue values[] = {
{VIPS_FOREIGN_NONE, "VIPS_FOREIGN_NONE", "none"},
{VIPS_FOREIGN_PARTIAL, "VIPS_FOREIGN_PARTIAL", "partial"},
{VIPS_FOREIGN_SEQUENTIAL, "VIPS_FOREIGN_SEQUENTIAL", "sequential"},
{VIPS_FOREIGN_BIGENDIAN, "VIPS_FOREIGN_BIGENDIAN", "bigendian"},
{VIPS_FOREIGN_SEQUENTIAL, "VIPS_FOREIGN_SEQUENTIAL", "sequential"},
{VIPS_FOREIGN_ALL, "VIPS_FOREIGN_ALL", "all"},
{0, NULL, NULL}
};

View File

@ -879,9 +879,9 @@ vips_image_build( VipsObject *object )
break;
case 'a':
/* Check parameters.
/* Ban crazy numbers.
*/
if( image->sizeof_header < 0 ) {
if( image->sizeof_header > 1000000 ) {
vips_error( "VipsImage", "%s", _( "bad parameters" ) );
return( -1 );
}

View File

@ -564,6 +564,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 ) )

View File

@ -132,11 +132,13 @@ char *name;
/* Find the x position of a file name (extract n from <root>.nxm.v).
*/
static int
find_x( name )
char *name;
{ int n;
find_x( char *name )
{
int n;
char *p;
char *out = strdup( name );
char *out;
out = strdup( name );
/* Chop off '.v'.
*/
@ -166,17 +168,21 @@ char *name;
return( -1 );
}
free( out );
return( n );
}
/* Find the y position of a file name (extract m from <root>.nxm.v).
*/
static int
find_y( name )
char *name;
{ int m;
find_y( char *name )
{
int m;
char *p;
char *out = strdup( name );
char *out;
out = strdup( name );
/* Chop off '.v'.
*/
@ -207,12 +213,10 @@ char *name;
}
free( out );
return( m );
}
static int
mosaic_analysis(int width, int height,IMAGE **inp, IMAGE *out,
int xoff, int yoff, int *vxdisp, int *vydisp,int *hxdisp, int *hydisp) {
@ -260,7 +264,7 @@ double scale1, angle1, dx1, dy1;
}
if( ( inp[curr_im]->Xsize < xoff ) || ( inp[curr_im+1]->Xsize < xoff ) ||
( inp[curr_im]->Ysize < yoff ) || ( inp[curr_im]->Ysize < yoff) ){
( inp[curr_im]->Ysize < yoff ) || ( inp[curr_im+1]->Ysize < yoff) ){
++curr_disp_x;
hxdisp[curr_disp_x] = 0;
hydisp[curr_disp_x] = 0;

View File

@ -258,11 +258,13 @@ char *name;
/* Find the x position of a file name (extract n from <root>.nxm.v).
*/
static int
find_x( name )
char *name;
{ int n;
find_x( char *name )
{
int n;
char *p;
char *out = strdup( name );
char *out;
out = strdup( name );
/* Chop off '.v'.
*/
@ -292,17 +294,21 @@ char *name;
return( -1 );
}
free( out );
return( n );
}
/* Find the y position of a file name (extract m from <root>.nxm.v).
*/
static int
find_y( name )
char *name;
{ int m;
find_y( char *name )
{
int m;
char *p;
char *out = strdup( name );
char *out;
out = strdup( name );
/* Chop off '.v'.
*/
@ -333,14 +339,10 @@ char *name;
}
free( out );
return( m );
}
/* Join two frames left-right. Have to open them and find their sizes.
*/
static int