[pacman-dev] [PATCH] mbscasecmp fails in 1% of time.

Tobias Stoeckmann tobias at stoeckmann.org
Fri Jun 10 16:40:45 UTC 2016

The width of wchar_t is allowed to be of the same width as long,
according to standards. The return type of mbscasecmp is int though.

On amd64 with a 32 bit int, this means that mbscasecmp can return
zero (indicating that strings are equal) even though the input
strings differ.

No known system exists that could trigger this.

Signed-off-by: Tobias Stoeckmann <tobias at stoeckmann.org>
There is a reason that I picked this one, annotation will help.
 src/pacman/util.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/pacman/util.c b/src/pacman/util.c
index 81780f7..e38ef06 100644
--- a/src/pacman/util.c
+++ b/src/pacman/util.c
@@ -1503,7 +1503,7 @@ int select_question(int count)
 	return (preset - 1);
-static int mbscasecmp(const char *s1, const char *s2)
+static wchar_t mbscasecmp(const char *s1, const char *s2)
 	size_t len1 = strlen(s1), len2 = strlen(s2);
 	wchar_t c1, c2;

More information about the pacman-dev mailing list