]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
IMPORT: ebtree: make string_equal_bits() return an unsigned
authorWilly Tarreau <w@1wt.eu>
Sat, 30 Dec 2023 16:24:06 +0000 (17:24 +0100)
committerWilly Tarreau <w@1wt.eu>
Sat, 6 Jan 2024 12:35:42 +0000 (13:35 +0100)
It used to return ssize_t for -1 but in fact we're using this -1 as
the largest possible value and the result is generally cast to signed
to check if the end was reached, so better make it clearly return an
unsigned value here.

This is cbtree commit e1e58a2b2ced2560d4544abaefde595273089704.
This is ebtree commit d7531a7475f8ba8e592342ef1240df3330d0ab47.

include/import/ebtree.h

index 7f02902df42be23bd1545a7fcd489d005f4ed983..31a9cac109c1a7685205fd1adb4915e66e257509 100644 (file)
@@ -836,7 +836,7 @@ static forceinline int check_bits(const unsigned char *a,
  * permitted. Equal strings are reported as a negative number of bits, which
  * indicates the end was reached.
  */
-static forceinline ssize_t string_equal_bits(const unsigned char *a,
+static forceinline size_t string_equal_bits(const unsigned char *a,
                                             const unsigned char *b,
                                             size_t ignore)
 {
@@ -857,7 +857,7 @@ static forceinline ssize_t string_equal_bits(const unsigned char *a,
                if (c)
                        break;
                if (!d)
-                       return -1;
+                       return (size_t)-1;
        }
        /* OK now we know that a and b differ at byte <beg>, or that both are zero.
         * We have to find what bit is differing and report it as the number of