Merge "Fix clang compiler warnings."
diff --git a/cvaux/src/cvcalibfilter.cpp b/cvaux/src/cvcalibfilter.cpp
index e6c4fc8..bc8f821 100644
--- a/cvaux/src/cvcalibfilter.cpp
+++ b/cvaux/src/cvcalibfilter.cpp
@@ -518,64 +518,61 @@
         return;
     }
 
-    if( latestCounts )
+    for( i = 0; i < cameraCount; i++ )
     {
-        for( i = 0; i < cameraCount; i++ )
+        if( dstarr[i] && latestCounts[i] )
         {
-            if( dstarr[i] && latestCounts[i] )
+            CvMat dst_stub, *dst;
+            int count = 0;
+            bool found = false;
+            CvPoint2D32f* pts = 0;
+
+            GetLatestPoints( i, &pts, &count, &found );
+
+            dst = cvGetMat( dstarr[i], &dst_stub );
+
+            static const CvScalar line_colors[] =
             {
-                CvMat dst_stub, *dst;
-                int count = 0;
-                bool found = false;
-                CvPoint2D32f* pts = 0;
+                {{0,0,255}},
+                {{0,128,255}},
+                {{0,200,200}},
+                {{0,255,0}},
+                {{200,200,0}},
+                {{255,0,0}},
+                {{255,0,255}}
+            };
 
-                GetLatestPoints( i, &pts, &count, &found );
+            const int colorCount = sizeof(line_colors)/sizeof(line_colors[0]);
+            const int r = 4;
+            CvScalar color = line_colors[0];
+            CvPoint prev_pt = { 0, 0};
 
-                dst = cvGetMat( dstarr[i], &dst_stub );
+            for( j = 0; j < count; j++ )
+            {
+                CvPoint pt;
+                pt.x = cvRound(pts[j].x);
+                pt.y = cvRound(pts[j].y);
 
-                static const CvScalar line_colors[] =
+                if( found )
                 {
-                    {{0,0,255}},
-                    {{0,128,255}},
-                    {{0,200,200}},
-                    {{0,255,0}},
-                    {{200,200,0}},
-                    {{255,0,0}},
-                    {{255,0,255}}
-                };
+                    if( etalonType == CV_CALIB_ETALON_CHESSBOARD )
+                        color = line_colors[(j/cvRound(etalonParams[0]))%colorCount];
+                    else
+                        color = CV_RGB(0,255,0);
 
-                const int colorCount = sizeof(line_colors)/sizeof(line_colors[0]);
-                const int r = 4;
-                CvScalar color = line_colors[0];
-                CvPoint prev_pt = { 0, 0};
-
-                for( j = 0; j < count; j++ )
-                {
-                    CvPoint pt;
-                    pt.x = cvRound(pts[j].x);
-                    pt.y = cvRound(pts[j].y);
-
-                    if( found )
-                    {
-                        if( etalonType == CV_CALIB_ETALON_CHESSBOARD )
-                            color = line_colors[(j/cvRound(etalonParams[0]))%colorCount];
-                        else
-                            color = CV_RGB(0,255,0);
-
-                        if( j != 0 )
-                            cvLine( dst, prev_pt, pt, color, 1, CV_AA );
-                    }
-
-                    cvLine( dst, cvPoint( pt.x - r, pt.y - r ),
-                            cvPoint( pt.x + r, pt.y + r ), color, 1, CV_AA );
-
-                    cvLine( dst, cvPoint( pt.x - r, pt.y + r),
-                            cvPoint( pt.x + r, pt.y - r), color, 1, CV_AA );
-
-                    cvCircle( dst, pt, r+1, color, 1, CV_AA );
-
-                    prev_pt = pt;
+                    if( j != 0 )
+                        cvLine( dst, prev_pt, pt, color, 1, CV_AA );
                 }
+
+                cvLine( dst, cvPoint( pt.x - r, pt.y - r ),
+                        cvPoint( pt.x + r, pt.y + r ), color, 1, CV_AA );
+
+                cvLine( dst, cvPoint( pt.x - r, pt.y + r),
+                        cvPoint( pt.x + r, pt.y - r), color, 1, CV_AA );
+
+                cvCircle( dst, pt, r+1, color, 1, CV_AA );
+
+                prev_pt = pt;
             }
         }
     }
diff --git a/cvaux/src/cvdpstereo.cpp b/cvaux/src/cvdpstereo.cpp
index 3527809..ce322d6 100644
--- a/cvaux/src/cvdpstereo.cpp
+++ b/cvaux/src/cvdpstereo.cpp
@@ -76,8 +76,10 @@
     uchar min_val, max_val;
 } _CvRightImData;
 
-#define CV_IMAX3(a,b,c) ((temp3 = (a) >= (b) ? (a) : (b)),(temp3 >= (c) ? temp3 : (c)))
-#define CV_IMIN3(a,b,c) ((temp3 = (a) <= (b) ? (a) : (b)),(temp3 <= (c) ? temp3 : (c)))
+// When CV_IMAX3 and CV_IMIN3 are used in the same expression, the evulation
+// order is undefined, and they should not assign to the same temporary variable.
+#define CV_IMAX3(a,b,c) ((max3 = (a) >= (b) ? (a) : (b)),(max3 >= (c) ?  max3 : (c)))
+#define CV_IMIN3(a,b,c) ((min3 = (a) <= (b) ? (a) : (b)),(min3 <= (c) ?  min3 : (c)))
 
 void icvFindStereoCorrespondenceByBirchfieldDP( uchar* src1, uchar* src2,
                                                 uchar* disparities,
@@ -87,7 +89,7 @@
                                                 float  _param3, float _param4,
                                                 float  _param5 )
 {
-    int     x, y, i, j, temp3;
+    int     x, y, i, j, max3, min3;
     int     d, s;
     int     dispH =  maxDisparity + 3; 
     uchar  *dispdata;