segmentation: Fix integer underflow check
authorSebastian Dröge <sebastian@centricular.com>
Sat, 8 Feb 2014 18:28:26 +0000 (19:28 +0100)
committerSebastian Dröge <sebastian@centricular.com>
Sat, 8 Feb 2014 18:28:26 +0000 (19:28 +0100)
error: comparison of unsigned expression < 0 is
always false [-Werror,-Wtautological-compare]

ext/opencv/gstsegmentation.cpp

index 1a48afd..1f81fca 100644 (file)
@@ -509,11 +509,13 @@ update_codebook (unsigned char *p, codeBook * c, unsigned *cbBounds,
   int matchChannel;
 
   for (n = 0; n < numChannels; n++) {
-    high[n] = *(p + n) + *(cbBounds + n);
+    high[n] = p[n] + cbBounds[n];
     if (high[n] > 255)
       high[n] = 255;
-    low[n] = *(p + n) - *(cbBounds + n);
-    if (low[n] < 0)
+
+    if (p[n] > cbBounds[n])
+      low[n] = p[n] - cbBounds[n];
+    else
       low[n] = 0;
   }