From: Yingxin Cheng Date: Thu, 29 Apr 2021 01:44:05 +0000 (+0800) Subject: crimson/onode-staged-tree: fix potential overflow in toMatchKindCMP() X-Git-Tag: v17.1.0~2016^2~7 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=30dec3ee14e5c4ad694506ef27e3f6bb4de999bc;p=ceph-ci.git crimson/onode-staged-tree: fix potential overflow in toMatchKindCMP() Signed-off-by: Yingxin Cheng --- diff --git a/src/crimson/os/seastore/onode_manager/staged-fltree/fwd.h b/src/crimson/os/seastore/onode_manager/staged-fltree/fwd.h index 890e1fcd08c..65aa3bf806b 100644 --- a/src/crimson/os/seastore/onode_manager/staged-fltree/fwd.h +++ b/src/crimson/os/seastore/onode_manager/staged-fltree/fwd.h @@ -73,8 +73,13 @@ inline MatchKindCMP toMatchKindCMP(int value) { } template 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(