Linux: Fix return value handling of mbstowcs()

This commit is contained in:
Thomas Perl
2012-07-18 00:42:47 +02:00
committed by Alan Ott
parent 48352615f0
commit 807afbc35c
+3 -2
View File
@@ -289,7 +289,7 @@ static int get_device_string(hid_device *dev, enum device_string_id key, wchar_t
ret = (ret == (size_t)-1)? -1: 0;
break;
case DEVICE_STRING_SERIAL:
mbstowcs(string, serial_number_utf8, maxlen);
ret = mbstowcs(string, serial_number_utf8, maxlen);
ret = (ret == (size_t)-1)? -1: 0;
break;
default:
@@ -317,7 +317,8 @@ static int get_device_string(hid_device *dev, enum device_string_id key, wchar_t
str = udev_device_get_sysattr_value(parent, key_str);
if (str) {
/* Convert the string from UTF-8 to wchar_t */
ret = (mbstowcs(string, str, maxlen) < 0)? -1: 0;
ret = mbstowcs(string, str, maxlen);
ret = (ret == (size_t)-1)? -1: 0;
goto end;
}
}