Fixed warnings about unused return value of fread

This commit is contained in:
Andrey Kamaev 2012-04-10 15:12:08 +00:00
parent 5f02bbd0d9
commit 7fd1cfc5e7
7 changed files with 44 additions and 29 deletions

View File

@ -1854,9 +1854,11 @@ int icvGetHaarTraininDataFromVecCallback( CvMat* img, void* userdata )
assert( img->rows * img->cols == ((CvVecFile*) userdata)->vecsize );
fread( &tmp, sizeof( tmp ), 1, ((CvVecFile*) userdata)->input );
fread( ((CvVecFile*) userdata)->vector, sizeof( short ),
size_t elements_read = fread( &tmp, sizeof( tmp ), 1, ((CvVecFile*) userdata)->input );
CV_Assert(elements_read == 1);
elements_read = fread( ((CvVecFile*) userdata)->vector, sizeof( short ),
((CvVecFile*) userdata)->vecsize, ((CvVecFile*) userdata)->input );
CV_Assert(elements_read == (size_t)((CvVecFile*) userdata)->vecsize);
if( feof( ((CvVecFile*) userdata)->input ) ||
(((CvVecFile*) userdata)->last)++ >= ((CvVecFile*) userdata)->count )
@ -1919,10 +1921,12 @@ int icvGetHaarTrainingDataFromVec( CvHaarTrainingData* data, int first, int coun
if( file.input != NULL )
{
fread( &file.count, sizeof( file.count ), 1, file.input );
fread( &file.vecsize, sizeof( file.vecsize ), 1, file.input );
fread( &tmp, sizeof( tmp ), 1, file.input );
fread( &tmp, sizeof( tmp ), 1, file.input );
size_t elements_read1 = fread( &file.count, sizeof( file.count ), 1, file.input );
size_t elements_read2 = fread( &file.vecsize, sizeof( file.vecsize ), 1, file.input );
size_t elements_read3 = fread( &tmp, sizeof( tmp ), 1, file.input );
size_t elements_read4 = fread( &tmp, sizeof( tmp ), 1, file.input );
CV_Assert(elements_read1 == 1 && elements_read2 == 1 && elements_read3 == 1 && elements_read4 == 1);
if( !feof( file.input ) )
{
if( file.vecsize != data->winsize.width * data->winsize.height )
@ -1970,10 +1974,11 @@ int icvGetHaarTrainingDataFromBG( CvHaarTrainingData* data, int first, int count
if( file.input != NULL )
{
fread( &file.count, sizeof( file.count ), 1, file.input );
fread( &file.vecsize, sizeof( file.vecsize ), 1, file.input );
fread( &tmp, sizeof( tmp ), 1, file.input );
fread( &tmp, sizeof( tmp ), 1, file.input );
size_t elements_read1 = fread( &file.count, sizeof( file.count ), 1, file.input );
size_t elements_read2 = fread( &file.vecsize, sizeof( file.vecsize ), 1, file.input );
size_t elements_read3 = fread( &tmp, sizeof( tmp ), 1, file.input );
size_t elements_read4 = fread( &tmp, sizeof( tmp ), 1, file.input );
CV_Assert(elements_read1 == 1 && elements_read2 == 1 && elements_read3 == 1 && elements_read4 == 1);
if( !feof( file.input ) )
{
if( file.vecsize != data->winsize.width * data->winsize.height )

View File

@ -884,10 +884,11 @@ void cvShowVecSamples( const char* filename, int winwidth, int winheight,
if( file.input != NULL )
{
fread( &file.count, sizeof( file.count ), 1, file.input );
fread( &file.vecsize, sizeof( file.vecsize ), 1, file.input );
fread( &tmp, sizeof( tmp ), 1, file.input );
fread( &tmp, sizeof( tmp ), 1, file.input );
size_t elements_read1 = fread( &file.count, sizeof( file.count ), 1, file.input );
size_t elements_read2 = fread( &file.vecsize, sizeof( file.vecsize ), 1, file.input );
size_t elements_read3 = fread( &tmp, sizeof( tmp ), 1, file.input );
size_t elements_read4 = fread( &tmp, sizeof( tmp ), 1, file.input );
CV_Assert(elements_read1 == 1 && elements_read2 == 1 && elements_read3 == 1 && elements_read4 == 1);
if( file.vecsize != winwidth * winheight )
{

View File

@ -150,8 +150,10 @@ bool CvCascadeImageReader::PosReader::get( Mat &_img )
{
CV_Assert( _img.rows * _img.cols == vecSize );
uchar tmp = 0;
fread( &tmp, sizeof( tmp ), 1, file );
fread( vec, sizeof( vec[0] ), vecSize, file );
size_t elements_read = fread( &tmp, sizeof( tmp ), 1, file );
CV_Assert(elements_read == 1);
elements_read = fread( vec, sizeof( vec[0] ), vecSize, file );
CV_Assert(elements_read == (size_t)(vecSize));
if( feof( file ) || last++ >= count )
return false;

View File

@ -269,13 +269,15 @@ static Mat readMatFromBin( const string& filename )
if( f )
{
int rows, cols, type, dataSize;
fread( (void*)&rows, sizeof(int), 1, f );
fread( (void*)&cols, sizeof(int), 1, f );
fread( (void*)&type, sizeof(int), 1, f );
fread( (void*)&dataSize, sizeof(int), 1, f );
size_t elements_read1 = fread( (void*)&rows, sizeof(int), 1, f );
size_t elements_read2 = fread( (void*)&cols, sizeof(int), 1, f );
size_t elements_read3 = fread( (void*)&type, sizeof(int), 1, f );
size_t elements_read4 = fread( (void*)&dataSize, sizeof(int), 1, f );
CV_Assert(elements_read1 == 1 && elements_read2 == 1 && elements_read3 == 1 && elements_read4 == 1);
uchar* data = (uchar*)cvAlloc(dataSize);
fread( (void*)data, 1, dataSize, f );
size_t elements_read = fread( (void*)data, 1, dataSize, f );
CV_Assert(elements_read == (size_t)(dataSize));
fclose(f);
return Mat( rows, cols, type, data );

View File

@ -268,13 +268,15 @@ static Mat readMatFromBin( const string& filename )
if( f )
{
int rows, cols, type, dataSize;
fread( (void*)&rows, sizeof(int), 1, f );
fread( (void*)&cols, sizeof(int), 1, f );
fread( (void*)&type, sizeof(int), 1, f );
fread( (void*)&dataSize, sizeof(int), 1, f );
size_t elements_read1 = fread( (void*)&rows, sizeof(int), 1, f );
size_t elements_read2 = fread( (void*)&cols, sizeof(int), 1, f );
size_t elements_read3 = fread( (void*)&type, sizeof(int), 1, f );
size_t elements_read4 = fread( (void*)&dataSize, sizeof(int), 1, f );
CV_Assert(elements_read1 == 1 && elements_read2 == 1 && elements_read3 == 1 && elements_read4 == 1);
uchar* data = (uchar*)cvAlloc(dataSize);
fread( (void*)data, 1, dataSize, f );
size_t elements_read = fread( (void*)data, 1, dataSize, f );
CV_Assert(elements_read == (size_t)(dataSize));
fclose(f);
return Mat( rows, cols, type, data );

View File

@ -1500,7 +1500,8 @@ cvLoadHaarClassifierCascade( const char* directory, CvSize orig_window_size )
fseek( f, 0, SEEK_END );
size = ftell( f );
fseek( f, 0, SEEK_SET );
fread( ptr, 1, size, f );
size_t elements_read = fread( ptr, 1, size, f );
CV_Assert(elements_read == (size_t)(size));
fclose(f);
input_cascade[i] = ptr;
ptr += size;

View File

@ -244,7 +244,8 @@ void parserRFilter (FILE * xmlf, int p, CvLSVMFilterObject * model, float *b){
}
if(tagVal == WEIGHTS){
data = (double *)malloc( sizeof(double) * p * sizeX * sizeY);
fread(data, sizeof(double), p * sizeX * sizeY, xmlf);
size_t elements_read = fread(data, sizeof(double), p * sizeX * sizeY, xmlf);
CV_Assert(elements_read == (size_t)(p * sizeX * sizeY));
model->H = (float *)malloc(sizeof(float)* p * sizeX * sizeY);
for(ii = 0; ii < p * sizeX * sizeY; ii++){
model->H[ii] = (float)data[ii];
@ -502,7 +503,8 @@ void parserPFilter (FILE * xmlf, int p, int /*N_path*/, CvLSVMFilterObject * mo
}
if(tagVal == WEIGHTS){
data = (double *)malloc( sizeof(double) * p * sizeX * sizeY);
fread(data, sizeof(double), p * sizeX * sizeY, xmlf);
size_t elements_read = fread(data, sizeof(double), p * sizeX * sizeY, xmlf);
CV_Assert(elements_read == (size_t)(p * sizeX * sizeY));
model->H = (float *)malloc(sizeof(float)* p * sizeX * sizeY);
for(ii = 0; ii < p * sizeX * sizeY; ii++){
model->H[ii] = (float)data[ii];