diff --git a/libvips/include/vips/memory.h b/libvips/include/vips/memory.h index bdcd0db7..99b26e8f 100644 --- a/libvips/include/vips/memory.h +++ b/libvips/include/vips/memory.h @@ -74,7 +74,7 @@ size_t vips_tracked_get_mem( void ); size_t vips_tracked_get_mem_highwater( void ); int vips_tracked_get_allocs( void ); -int vips_tracked_open( const char *pathname, int flags, ... ); +int vips_tracked_open( const char *pathname, int flags, mode_t mode ); int vips_tracked_close( int fd ); int vips_tracked_get_files( void ); diff --git a/libvips/include/vips/util.h b/libvips/include/vips/util.h index 82862f4c..6cceac82 100644 --- a/libvips/include/vips/util.h +++ b/libvips/include/vips/util.h @@ -254,7 +254,7 @@ int vips_filename_suffix_match( const char *path, const char *suffixes[] ); gint64 vips_file_length( int fd ); int vips__write( int fd, const void *buf, size_t count ); -int vips__open( const char *filename, int flags, ... ); +int vips__open( const char *filename, int flags, mode_t mode ); int vips__open_read( const char *filename ); FILE *vips__fopen( const char *filename, const char *mode ); diff --git a/libvips/iofuncs/memory.c b/libvips/iofuncs/memory.c index 517cf301..2233b17b 100644 --- a/libvips/iofuncs/memory.c +++ b/libvips/iofuncs/memory.c @@ -356,7 +356,7 @@ vips_tracked_malloc( size_t size ) * vips_tracked_open: * @pathname: name of file to open * @flags: flags for open() - * @...: open mode + * @mode: open mode * * Exactly as open(2), but the number of files currently open via * vips_tracked_open() is available via vips_tracked_get_files(). This is used @@ -372,18 +372,9 @@ vips_tracked_malloc( size_t size ) * Returns: a file descriptor, or -1 on error. */ int -vips_tracked_open( const char *pathname, int flags, ... ) +vips_tracked_open( const char *pathname, int flags, mode_t mode ) { int fd; - mode_t mode; - va_list ap; - - /* mode_t is promoted to int in ..., so we have to pull it out as an - * int. - */ - va_start( ap, flags ); - mode = va_arg( ap, int ); - va_end( ap ); if( (fd = vips__open( pathname, flags, mode )) == -1 ) return( -1 ); diff --git a/libvips/iofuncs/source.c b/libvips/iofuncs/source.c index 4f07b0ce..b20c5b58 100644 --- a/libvips/iofuncs/source.c +++ b/libvips/iofuncs/source.c @@ -596,7 +596,7 @@ vips_source_unminimise( VipsSource *source ) int fd; if( (fd = vips_tracked_open( connection->filename, - MODE_READ )) == -1 ) { + MODE_READ, 0 )) == -1 ) { vips_error_system( errno, vips_connection_nick( connection ), "%s", _( "unable to open for read" ) ); diff --git a/libvips/iofuncs/util.c b/libvips/iofuncs/util.c index 1aa5253a..7bff459f 100644 --- a/libvips/iofuncs/util.c +++ b/libvips/iofuncs/util.c @@ -624,15 +624,9 @@ vips__set_create_time( int fd ) /* open() with a utf8 filename, setting errno. */ int -vips__open( const char *filename, int flags, ... ) +vips__open( const char *filename, int flags, mode_t mode ) { int fd; - mode_t mode; - va_list ap; - - va_start( ap, flags ); - mode = va_arg( ap, int ); - va_end( ap ); /* Various bad things happen if you accidentally open a directory as a * file. @@ -655,7 +649,7 @@ vips__open( const char *filename, int flags, ... ) int vips__open_read( const char *filename ) { - return( vips__open( filename, MODE_READONLY ) ); + return( vips__open( filename, MODE_READONLY, 0 ) ); } /* fopen() with utf8 filename and mode, setting errno. diff --git a/libvips/iofuncs/vips.c b/libvips/iofuncs/vips.c index b7b62ef8..16e74759 100644 --- a/libvips/iofuncs/vips.c +++ b/libvips/iofuncs/vips.c @@ -165,11 +165,11 @@ vips__open_image_read( const char *filename ) * work. When we later mmap this file, we set read-only, so there * is little danger of scrubbing over files we own. */ - fd = vips_tracked_open( filename, MODE_READWRITE ); + fd = vips_tracked_open( filename, MODE_READWRITE, 0 ); if( fd == -1 ) /* Open read-write failed. Fall back to open read-only. */ - fd = vips_tracked_open( filename, MODE_READONLY ); + fd = vips_tracked_open( filename, MODE_READONLY, 0 ); if( fd == -1 ) { vips_error_system( errno, "VipsImage",