From f6ef504ef0f9a243d434684435d1129c0d1a8ad2 Mon Sep 17 00:00:00 2001 From: Andrey Kamaev Date: Wed, 20 Jun 2012 21:09:27 +0000 Subject: [PATCH] Fixed few more warnings/bugs. --- modules/core/src/persistence.cpp | 58 ++++++++++++++++---------------- modules/legacy/src/texture.cpp | 2 +- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/modules/core/src/persistence.cpp b/modules/core/src/persistence.cpp index 530dcdaec..2f8193410 100644 --- a/modules/core/src/persistence.cpp +++ b/modules/core/src/persistence.cpp @@ -257,11 +257,11 @@ typedef struct CvFileStorage CvWriteString write_string; CvWriteComment write_comment; CvStartNextStream start_next_stream; - + const char* strbuf; size_t strbufsize, strbufpos; std::deque* outbuf; - + bool is_opened; } CvFileStorage; @@ -543,10 +543,10 @@ icvClose( CvFileStorage* fs, std::string* out ) { if( out ) out->clear(); - + if( !fs ) CV_Error( CV_StsNullPtr, "NULL double pointer to file storage" ); - + if( fs->is_opened ) { if( fs->write_mode && (fs->file || fs->gzfile || fs->outbuf) ) @@ -560,10 +560,10 @@ icvClose( CvFileStorage* fs, std::string* out ) if( fs->fmt == CV_STORAGE_FORMAT_XML ) icvPuts( fs, "\n" ); } - + icvCloseFile(fs); } - + if( fs->outbuf && out ) { out->resize(fs->outbuf->size()); @@ -578,21 +578,21 @@ cvReleaseFileStorage( CvFileStorage** p_fs ) { if( !p_fs ) CV_Error( CV_StsNullPtr, "NULL double pointer to file storage" ); - + if( *p_fs ) { CvFileStorage* fs = *p_fs; *p_fs = 0; - + icvClose(fs, 0); - - cvReleaseMemStorage( &fs->strstorage ); + + cvReleaseMemStorage( &fs->strstorage ); cvFree( &fs->buffer_start ); cvReleaseMemStorage( &fs->memstorage ); - + if( fs->outbuf ) delete fs->outbuf; - + memset( fs, 0, sizeof(*fs) ); cvFree( &fs ); } @@ -2697,7 +2697,7 @@ cvOpenFileStorage( const char* filename, CvMemStorage* dststorage, int flags, co } else fnamelen = strlen(filename); - + if( mem && append ) CV_Error( CV_StsBadFlag, "CV_STORAGE_APPEND and CV_STORAGE_MEMORY are not currently compatible" ); @@ -2709,7 +2709,7 @@ cvOpenFileStorage( const char* filename, CvMemStorage* dststorage, int flags, co fs->flags = CV_FILE_STORAGE; fs->write_mode = write_mode; - + if( !mem ) { fs->filename = (char*)cvMemStorageAlloc( fs->memstorage, fnamelen+1 ); @@ -2747,7 +2747,7 @@ cvOpenFileStorage( const char* filename, CvMemStorage* dststorage, int flags, co #endif } } - + fs->roots = 0; fs->struct_indent = 0; fs->struct_flags = 0; @@ -2756,10 +2756,10 @@ cvOpenFileStorage( const char* filename, CvMemStorage* dststorage, int flags, co if( fs->write_mode ) { int fmt = flags & CV_STORAGE_FORMAT_MASK; - + if( mem ) fs->outbuf = new std::deque; - + if( fmt == CV_STORAGE_FORMAT_AUTO && filename ) { const char* dot_pos = filename + fnamelen - (isGZ ? 7 : 4); @@ -2769,7 +2769,7 @@ cvOpenFileStorage( const char* filename, CvMemStorage* dststorage, int flags, co } else fs->fmt = fmt != CV_STORAGE_FORMAT_AUTO ? fmt : CV_STORAGE_FORMAT_XML; - + // we use factor=6 for XML (the longest characters (' and ") are encoded with 6 bytes (' and ") // and factor=4 for YAML ( as we use 4 bytes for non ASCII characters (e.g. \xAB)) int buf_size = CV_FS_MAX_LEN*(fs->fmt == CV_STORAGE_FORMAT_XML ? 6 : 4) + 1024; @@ -2871,7 +2871,7 @@ cvOpenFileStorage( const char* filename, CvMemStorage* dststorage, int flags, co fs->strbuf = filename; fs->strbufsize = fnamelen; } - + size_t buf_size = 1 << 20; const char* yaml_signature = "%YAML:"; char buf[16]; @@ -2917,7 +2917,7 @@ cvOpenFileStorage( const char* filename, CvMemStorage* dststorage, int flags, co fs->buffer = fs->buffer_end = 0; } fs->is_opened = true; - + _exit_: if( fs ) { @@ -3120,7 +3120,7 @@ cvWriteRawData( CvFileStorage* fs, const void* _data, int len, const char* dt ) if( !len ) return; - + if( !data0 ) CV_Error( CV_StsNullPtr, "Null data pointer" ); @@ -3564,7 +3564,7 @@ icvReadMat( CvFileStorage* fs, CvFileNode* node ) cols = cvReadIntByName( fs, node, "cols", -1 ); dt = cvReadStringByName( fs, node, "dt", 0 ); - if( rows < 0 || cols < 0 || dt < 0 ) + if( rows < 0 || cols < 0 || !dt ) CV_Error( CV_StsError, "Some of essential matrix attributes are absent" ); elem_type = icvDecodeSimpleFormat( dt ); @@ -4632,7 +4632,7 @@ icvReadGraph( CvFileStorage* fs, CvFileNode* node ) if( header_dt ) header_size = icvCalcElemSize( header_dt, header_size ); - if( vtx_dt > 0 ) + if( vtx_dt ) { src_vtx_size = icvCalcElemSize( vtx_dt, 0 ); vtx_size = icvCalcElemSize( vtx_dt, vtx_size ); @@ -5192,16 +5192,16 @@ void FileStorage::release() string FileStorage::releaseAndGetString() { - string buf; + string buf; if( fs.obj && fs.obj->outbuf ) icvClose(fs.obj, &buf); - + fs.release(); structs.clear(); state = UNDEFINED; - return buf; -} - + return buf; +} + FileNode FileStorage::root(int streamidx) const { return isOpened() ? FileNode(fs, cvGetRootFileNode(fs, streamidx)) : FileNode(); @@ -5498,7 +5498,7 @@ void write( FileStorage& fs, const string& name, const SparseMat& value ) Ptr mat = (CvSparseMat*)value; cvWrite( *fs, name.size() ? name.c_str() : 0, mat ); } - + WriteStructContext::WriteStructContext(FileStorage& _fs, const string& name, int flags, const string& typeName) : fs(&_fs) diff --git a/modules/legacy/src/texture.cpp b/modules/legacy/src/texture.cpp index 0aceea672..4b7cb061c 100644 --- a/modules/legacy/src/texture.cpp +++ b/modules/legacy/src/texture.cpp @@ -469,7 +469,7 @@ icvCreateGLCMDescriptors_AllowDoubleNest( CvGLCM* destGLCM, int matrixIndex ) descriptors[ CV_GLCMDESC_ENERGY ] += entryValue*entryValue; } - if( marginalProbability>0 ) + if( marginalProbability[ actualSideLoop1 ] > 0 ) marginalProbabilityEntropy += marginalProbability[ actualSideLoop1 ]*log(marginalProbability[ actualSideLoop1 ]); }