linux: Fix bug on mbstowcs() usage

In case of error mbstowcs() returns (size_t) -1
It is not a negative value since mbstowcs() returns a size_t (unsigned)

Fix compiler warning:
hid.c: In function 'utf8_to_wchar_t':
hid.c:105:3: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]
This commit is contained in:
Ludovic Rousseau 2012-09-21 11:01:50 +02:00 committed by Alan Ott
parent ee808f9dfc
commit 367fc3f3aa

View File

@ -102,7 +102,7 @@ static wchar_t *utf8_to_wchar_t(const char *utf8)
if (utf8) {
size_t wlen = mbstowcs(NULL, utf8, 0);
if (wlen < 0) {
if ((size_t) -1 == wlen) {
return wcsdup(L"");
}
ret = calloc(wlen+1, sizeof(wchar_t));