From a58d441dae6898fc905e92f9197b76a922faadfb Mon Sep 17 00:00:00 2001 From: Ady Abraham Date: Mon, 10 Oct 2022 18:44:47 +0000 Subject: [PATCH] Fix a bugprone-suspicious-memory-comparison warning Bug: 252789852 Change-Id: I2afa8907e260e547f82e3fdf4127799221c05aa5 Test: existing tests --- libs/hwui/Rect.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libs/hwui/Rect.h b/libs/hwui/Rect.h index 24443c8c98365..7170226037f9f 100644 --- a/libs/hwui/Rect.h +++ b/libs/hwui/Rect.h @@ -71,9 +71,14 @@ public: , right(rect.fRight) , bottom(rect.fBottom) {} - friend int operator==(const Rect& a, const Rect& b) { return !memcmp(&a, &b, sizeof(a)); } + friend int operator==(const Rect& a, const Rect& b) { + return a.left == b.left && + a.top == b.top && + a.right == b.right && + a.bottom == b.bottom; + } - friend int operator!=(const Rect& a, const Rect& b) { return memcmp(&a, &b, sizeof(a)); } + friend int operator!=(const Rect& a, const Rect& b) { return !(a == b); } inline void clear() { left = top = right = bottom = 0.0f; }