From: Douglas Bagnall Date: Fri, 15 Mar 2024 02:47:55 +0000 (+1300) Subject: pyldb: ldb_msg_richcmp: avoid one intransitive compare X-Git-Tag: tdb-1.4.11~1400 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bf654a046754c1ceaf669fb7e9f36eddc3266a28;p=thirdparty%2Fsamba.git pyldb: ldb_msg_richcmp: avoid one intransitive compare Signed-off-by: Douglas Bagnall Reviewed-by: Andrew Bartlett --- diff --git a/lib/ldb/pyldb.c b/lib/ldb/pyldb.c index 42badbc2e37..60ec4d299c4 100644 --- a/lib/ldb/pyldb.c +++ b/lib/ldb/pyldb.c @@ -4037,9 +4037,11 @@ static PyObject *py_ldb_msg_richcmp(PyLdbMessageObject *py_msg1, } } - ret = msg1->num_elements - msg2->num_elements; - if (ret != 0) { - return richcmp(ret, op); + if (msg1->num_elements > msg2->num_elements) { + return richcmp(1, op); + } + if (msg1->num_elements < msg2->num_elements) { + return richcmp(-1, op); } for (i = 0; i < msg1->num_elements; i++) {