From 0bd68a70f141d4f98dbe75339740ef2ad83ff74f Mon Sep 17 00:00:00 2001 From: Vadim Pisarevsky Date: Tue, 28 Aug 2012 13:45:35 +0400 Subject: [PATCH] fixed #2297, #2300; fixed several warnings --- modules/core/include/opencv2/core/mat.hpp | 2 +- modules/core/include/opencv2/core/operations.hpp | 13 +++++++------ modules/core/src/array.cpp | 2 +- modules/core/src/cmdparser.cpp | 4 +++- modules/core/src/opengl_interop.cpp | 4 ++-- modules/core/src/persistence.cpp | 2 +- modules/core/test/test_ds.cpp | 8 ++++---- modules/core/test/test_rand.cpp | 2 +- modules/flann/include/opencv2/flann/lsh_index.h | 4 ++-- modules/photo/src/fast_nlmeans_denoising_invoker.hpp | 2 +- modules/photo/src/fast_nlmeans_multi_denoising_invoker.hpp | 2 +- modules/ts/src/ts_gtest.cpp | 4 +++- 12 files changed, 27 insertions(+), 22 deletions(-) diff --git a/modules/core/include/opencv2/core/mat.hpp b/modules/core/include/opencv2/core/mat.hpp index ccc0257..92301cf 100644 --- a/modules/core/include/opencv2/core/mat.hpp +++ b/modules/core/include/opencv2/core/mat.hpp @@ -404,7 +404,7 @@ inline bool Mat::empty() const { return data == 0 || total() == 0; } inline size_t Mat::total() const { if( dims <= 2 ) - return rows*cols; + return (size_t)rows*cols; size_t p = 1; for( int i = 0; i < dims; i++ ) p *= size[i]; diff --git a/modules/core/include/opencv2/core/operations.hpp b/modules/core/include/opencv2/core/operations.hpp index 932d9fb..af89bbf 100644 --- a/modules/core/include/opencv2/core/operations.hpp +++ b/modules/core/include/opencv2/core/operations.hpp @@ -866,7 +866,7 @@ template struct CV_EXPORTS Matx_FastSolveOp template struct CV_EXPORTS Matx_FastSolveOp<_Tp, 2, 1> { bool operator()(const Matx<_Tp, 2, 2>& a, const Matx<_Tp, 2, 1>& b, - Matx<_Tp, 2, 1>& x, int method) const + Matx<_Tp, 2, 1>& x, int) const { _Tp d = determinant(a); if( d == 0 ) @@ -1244,7 +1244,7 @@ template<> inline Vec Vec::conj() const return conjugate(*this); } -template inline Vec<_Tp, cn> Vec<_Tp, cn>::cross(const Vec<_Tp, cn>& v) const +template inline Vec<_Tp, cn> Vec<_Tp, cn>::cross(const Vec<_Tp, cn>&) const { CV_Error(CV_StsError, "for arbitrary-size vector there is no cross-product defined"); return Vec<_Tp, cn>(); @@ -2466,7 +2466,8 @@ dot(const Vector<_Tp>& v1, const Vector<_Tp>& v2) { const _Tp *ptr1 = &v1[0], *ptr2 = &v2[0]; #if CV_ENABLE_UNROLLED - for(; i <= n - 4; i += 4 ) + const size_t n2 = (n > 4) ? n : 4; + for(; i <= n2 - 4; i += 4 ) s += (_Tw)ptr1[i]*ptr2[i] + (_Tw)ptr1[i+1]*ptr2[i+1] + (_Tw)ptr1[i+2]*ptr2[i+2] + (_Tw)ptr1[i+3]*ptr2[i+3]; #endif @@ -2500,7 +2501,7 @@ inline RNG::operator double() unsigned t = next(); return (((uint64)t << 32) | next())*5.4210108624275221700372640043497e-20; } -inline int RNG::uniform(int a, int b) { return a == b ? a : next()%(b - a) + a; } +inline int RNG::uniform(int a, int b) { return a == b ? a : (int)(next()%(b - a) + a); } inline float RNG::uniform(float a, float b) { return ((float)*this)*(b - a) + a; } inline double RNG::uniform(double a, double b) { return ((double)*this)*(b - a) + a; } @@ -2937,8 +2938,8 @@ inline bool FileNode::isNamed() const { return !node ? false : (node->tag & NAME inline size_t FileNode::size() const { int t = type(); - return t == MAP ? ((CvSet*)node->data.map)->active_count : - t == SEQ ? node->data.seq->total : (size_t)!isNone(); + return t == MAP ? (size_t)((CvSet*)node->data.map)->active_count : + t == SEQ ? (size_t)node->data.seq->total : (size_t)!isNone(); } inline CvFileNode* FileNode::operator *() { return (CvFileNode*)node; } diff --git a/modules/core/src/array.cpp b/modules/core/src/array.cpp index f065a1e..c9060bf 100644 --- a/modules/core/src/array.cpp +++ b/modules/core/src/array.cpp @@ -861,7 +861,7 @@ cvCreateData( CvArr* arr ) if( CV_IS_MAT_CONT( mat->type )) { total_size = (size_t)mat->dim[0].size*(mat->dim[0].step != 0 ? - mat->dim[0].step : total_size); + (size_t)mat->dim[0].step : total_size); } else { diff --git a/modules/core/src/cmdparser.cpp b/modules/core/src/cmdparser.cpp index b5c838c..d7be054 100644 --- a/modules/core/src/cmdparser.cpp +++ b/modules/core/src/cmdparser.cpp @@ -7,7 +7,8 @@ using namespace std; using namespace cv; namespace { -void helpParser() +#if 0 +static void helpParser() { printf("\nThe CommandLineParser class is designed for command line arguments parsing\n" "Keys map: \n" @@ -50,6 +51,7 @@ void helpParser() " It also works with 'unsigned int', 'double', and 'float' types \n" ); } +#endif vector split_string(const string& str, const string& delimiters) { diff --git a/modules/core/src/opengl_interop.cpp b/modules/core/src/opengl_interop.cpp index bf9deaa..5895363 100644 --- a/modules/core/src/opengl_interop.cpp +++ b/modules/core/src/opengl_interop.cpp @@ -113,13 +113,13 @@ namespace const CvOpenGlFuncTab* g_glFuncTab = 0; -//#ifdef HAVE_CUDA +#if defined HAVE_CUDA || defined HAVE_OPENGL const CvOpenGlFuncTab* glFuncTab() { static EmptyGlFuncTab empty; return g_glFuncTab ? g_glFuncTab : ∅ } -//#endif +#endif } CvOpenGlFuncTab::~CvOpenGlFuncTab() diff --git a/modules/core/src/persistence.cpp b/modules/core/src/persistence.cpp index 049b7fb..d060ac3 100644 --- a/modules/core/src/persistence.cpp +++ b/modules/core/src/persistence.cpp @@ -2793,7 +2793,7 @@ cvOpenFileStorage( const char* filename, CvMemStorage* dststorage, int flags, co fs->buffer_end = fs->buffer_start + buf_size; if( fs->fmt == CV_STORAGE_FORMAT_XML ) { - size_t file_size = fs->file ? ftell( fs->file ) : (size_t)0; + size_t file_size = fs->file ? (size_t)ftell( fs->file ) : (size_t)0; fs->strstorage = cvCreateChildMemStorage( fs->memstorage ); if( !append || file_size == 0 ) { diff --git a/modules/core/test/test_ds.cpp b/modules/core/test/test_ds.cpp index 7a5c6f1..d797860 100644 --- a/modules/core/test/test_ds.cpp +++ b/modules/core/test/test_ds.cpp @@ -845,7 +845,7 @@ int Core_SeqBaseTest::test_seq_ops( int iters ) cvtest::randUni( rng, elem_mat, cvScalarAll(0), cvScalarAll(255) ); whence = op - 7; - pos = whence < 0 ? 0 : whence > 0 ? sseq->count : cvtest::randInt(rng) % (sseq->count+1); + pos = whence < 0 ? 0 : whence > 0 ? sseq->count : (int)(cvtest::randInt(rng) % (sseq->count+1)); if( whence != 0 ) { cvSeqPushMulti( seq, elem, count, whence < 0 ); @@ -866,8 +866,8 @@ int Core_SeqBaseTest::test_seq_ops( int iters ) if( sseq->count > 0 ) { // choose the random element among the added - pos = count > 0 ? cvtest::randInt(rng) % count + pos : MAX(pos-1,0); - elem2 = cvGetSeqElem( seq, pos ); + pos = count > 0 ? (int)(cvtest::randInt(rng) % count + pos) : MAX(pos-1,0); + elem2 = cvGetSeqElem( seq, pos ); CV_TS_SEQ_CHECK_CONDITION( elem2 != 0, "multi push operation doesn't add elements" ); CV_TS_SEQ_CHECK_CONDITION( seq->total == sseq->count && memcmp( elem2, cvTsSimpleSeqElem(sseq,pos), elem_size) == 0, @@ -889,7 +889,7 @@ int Core_SeqBaseTest::test_seq_ops( int iters ) count = cvtest::randInt(rng) % (sseq->count+1); whence = op - 10; pos = whence < 0 ? 0 : whence > 0 ? sseq->count - count : - cvtest::randInt(rng) % (sseq->count - count + 1); + (int)(cvtest::randInt(rng) % (sseq->count - count + 1)); if( whence != 0 ) { diff --git a/modules/core/test/test_rand.cpp b/modules/core/test/test_rand.cpp index 8fab165..e93415b 100644 --- a/modules/core/test/test_rand.cpp +++ b/modules/core/test/test_rand.cpp @@ -168,7 +168,7 @@ void Core_RandTest::run( int ) int sz = 0, dsz = 0, slice; for( slice = 0; slice < maxSlice; slice++, sz += dsz ) { - dsz = slice+1 < maxSlice ? cvtest::randInt(rng) % (SZ - sz + 1) : SZ - sz; + dsz = slice+1 < maxSlice ? (int)(cvtest::randInt(rng) % (SZ - sz + 1)) : SZ - sz; Mat aslice = arr[k].colRange(sz, sz + dsz); tested_rng.fill(aslice, dist_type, A, B); } diff --git a/modules/flann/include/opencv2/flann/lsh_index.h b/modules/flann/include/opencv2/flann/lsh_index.h index fc4cebb..13627ca 100644 --- a/modules/flann/include/opencv2/flann/lsh_index.h +++ b/modules/flann/include/opencv2/flann/lsh_index.h @@ -260,8 +260,8 @@ private: * @param k_nn the number of nearest neighbors * @param checked_average used for debugging */ - void getNeighbors(const ElementType* vec, bool do_radius, float radius, bool do_k, unsigned int k_nn, - float& checked_average) + void getNeighbors(const ElementType* vec, bool /*do_radius*/, float radius, bool do_k, unsigned int k_nn, + float& /*checked_average*/) { static std::vector score_index_heap; diff --git a/modules/photo/src/fast_nlmeans_denoising_invoker.hpp b/modules/photo/src/fast_nlmeans_denoising_invoker.hpp index 6724e82..82839c9 100644 --- a/modules/photo/src/fast_nlmeans_denoising_invoker.hpp +++ b/modules/photo/src/fast_nlmeans_denoising_invoker.hpp @@ -62,7 +62,7 @@ struct FastNlMeansDenoisingInvoker { void operator() (const BlockedRange& range) const; - void operator= (const FastNlMeansDenoisingInvoker& invoker) { + void operator= (const FastNlMeansDenoisingInvoker&) { CV_Error(CV_StsNotImplemented, "Assigment operator is not implemented"); } diff --git a/modules/photo/src/fast_nlmeans_multi_denoising_invoker.hpp b/modules/photo/src/fast_nlmeans_multi_denoising_invoker.hpp index 602007e..f8d387c 100644 --- a/modules/photo/src/fast_nlmeans_multi_denoising_invoker.hpp +++ b/modules/photo/src/fast_nlmeans_multi_denoising_invoker.hpp @@ -63,7 +63,7 @@ struct FastNlMeansMultiDenoisingInvoker { void operator() (const BlockedRange& range) const; - void operator= (const FastNlMeansMultiDenoisingInvoker& invoker) { + void operator= (const FastNlMeansMultiDenoisingInvoker&) { CV_Error(CV_StsNotImplemented, "Assigment operator is not implemented"); } diff --git a/modules/ts/src/ts_gtest.cpp b/modules/ts/src/ts_gtest.cpp index f2cd000..2a46570 100644 --- a/modules/ts/src/ts_gtest.cpp +++ b/modules/ts/src/ts_gtest.cpp @@ -5896,7 +5896,7 @@ bool SkipPrefix(const char* prefix, const char** pstr) { // part can be omitted. // // Returns the value of the flag, or NULL if the parsing failed. -const char* ParseFlagValue(const char* str, +static const char* ParseFlagValue(const char* str, const char* flag, bool def_optional) { // str and flag must not be NULL. @@ -7221,12 +7221,14 @@ void StackLowerThanAddress(const void* ptr, bool* result) { *result = (&dummy < ptr); } +#if GTEST_HAS_CLONE static bool StackGrowsDown() { int dummy; bool result; StackLowerThanAddress(&dummy, &result); return result; } +#endif // Spawns a child process with the same executable as the current process in // a thread-safe manner and instructs it to run the death test. The -- 2.7.4