This function returns -1 as error value, which would be lost if immediately assigned to an unsigned type. Change-Id: If9050b793519a529df671527c3a3e33ca2afc1bd