]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
crimson/onode-staged-tree: fix potential overflow in toMatchKindCMP()
authorYingxin Cheng <yingxin.cheng@intel.com>
Thu, 29 Apr 2021 01:44:05 +0000 (09:44 +0800)
committerYingxin Cheng <yingxin.cheng@intel.com>
Sat, 8 May 2021 02:04:46 +0000 (10:04 +0800)
Signed-off-by: Yingxin Cheng <yingxin.cheng@intel.com>
src/crimson/os/seastore/onode_manager/staged-fltree/fwd.h

index 890e1fcd08c0721c876d2288de59ee7d8bd29420..65aa3bf806bd6837b558d3bd971dcf066a94dbfe 100644 (file)
@@ -73,8 +73,13 @@ inline MatchKindCMP toMatchKindCMP(int value) {
 }
 template <typename Type>
 MatchKindCMP toMatchKindCMP(const Type& l, const Type& r) {
-  int match = l - r;
-  return toMatchKindCMP(match);
+  if (l > r) {
+    return MatchKindCMP::GT;
+  } else if (l < r) {
+    return MatchKindCMP::LT;
+  } else {
+    return MatchKindCMP::EQ;
+  }
 }
 
 inline MatchKindCMP toMatchKindCMP(