From ceb4ffdb5575f2a7d628b3cbe73bf7d99f28f57a Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Sat, 23 Aug 2008 07:48:47 +0000 Subject: [PATCH] stuff --- libsrc/iofuncs/util.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/libsrc/iofuncs/util.c b/libsrc/iofuncs/util.c index fb545873..738bb35d 100644 --- a/libsrc/iofuncs/util.c +++ b/libsrc/iofuncs/util.c @@ -1011,23 +1011,25 @@ im__ftruncate( int fd, gint64 pos ) return( 0 ); } - /* Like fwrite(), but returns non-zero on error and sets error message. */ int im__file_write( void *data, size_t size, size_t nmemb, FILE *stream ) { - int n; - if( !data ) return( 0 ); - if( (n = fwrite( data, size, nmemb, stream )) != nmemb ) { - im_error( "im__file_write", - _( "writing error (%d out of %d blocks written) ... disc full?" ), - n, nmemb ); - return( -1 ); - } - return( 0 ); -} + size_t n; + if( !data ) + return( 0 ); + + if( (n = fwrite( data, size, nmemb, stream )) != nmemb ) { + im_error( "im__file_write", + _( "writing error (%zd out of %zd blocks written) " + "... disc full?" ), n, nmemb ); + return( -1 ); + } + + return( 0 ); +} /* Check whether arch corresponds to native byte order. */