Skip to content

Commit

Permalink
Linux: Fix return value handling of mbstowcs()
Browse files Browse the repository at this point in the history
  • Loading branch information
thp authored and signal11 committed Jul 18, 2012
1 parent 4835261 commit 807afbc
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions linux/hid.c
Expand Up @@ -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:
Expand Down Expand Up @@ -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;
}
}
Expand Down

0 comments on commit 807afbc

Please sign in to comment.