From 9981b39b5c7758145f1c339de4096ad8ac0d1c7c Mon Sep 17 00:00:00 2001
From: Sergei Golubchik <serg@mariadb.org>
Date: Sat, 14 Sep 2024 17:54:28 +0200
Subject: [PATCH] fixup MDEV-27277 Add a warning when max_sort_length is
 reached Step#1
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

fulltest2:

/home/buildbot/buildbot/build/mariadb-11.7.0/strings/ctype-mb.c: In function ‘my_strnxfrm_mb_internal’:
/home/buildbot/buildbot/build/mariadb-11.7.0/strings/ctype-mb.c:504:47: error: signed and unsigned type in conditional expression [-Werror=sign-compare]
       size_t len= (dst + chlen <= de) ? chlen : de - dst;

/home/buildbot/buildbot/build/mariadb-11.7.0/strings/ctype-utf8.c: In function ‘my_strnxfrm_unicode_full_bin’:
/home/buildbot/buildbot/build/mariadb-11.7.0/strings/ctype-utf8.c:318:20: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
     if ((de - dst) < nweights * 3)
---
 strings/ctype-mb.c   | 2 +-
 strings/ctype-utf8.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/strings/ctype-mb.c b/strings/ctype-mb.c
index 6ccb07f26e3..c5c44700104 100644
--- a/strings/ctype-mb.c
+++ b/strings/ctype-mb.c
@@ -501,7 +501,7 @@ my_strnxfrm_ret_t my_strnxfrm_mb_internal(CHARSET_INFO *cs,
     else
     {
       /* Multi-byte character */
-      size_t len= (dst + chlen <= de) ? chlen : de - dst;
+      size_t len= (dst + chlen <= de) ? (size_t) chlen : (size_t) (de - dst);
       if (dst + chlen > de)
         warnings|= MY_STRNXFRM_TRUNCATED_WEIGHT_REAL_CHAR;
       memcpy(dst, src, len);
diff --git a/strings/ctype-utf8.c b/strings/ctype-utf8.c
index b3e857be27a..4b95136c471 100644
--- a/strings/ctype-utf8.c
+++ b/strings/ctype-utf8.c
@@ -315,7 +315,7 @@ my_strnxfrm_unicode_full_bin(CHARSET_INFO *cs,
 
   if (flags & MY_STRXFRM_PAD_WITH_SPACE)
   {
-    if ((de - dst) < nweights * 3)
+    if ((uint)(de - dst) < nweights * 3)
       rc.m_warnings|= MY_STRNXFRM_TRUNCATED_WEIGHT_TRAILING_SPACE;
     for ( ; dst < de && nweights; nweights--)
     {
-- 
2.30.9