opengl: Fix QemuPipeStream::readFully reading beyond end of buffer

When GPU emulation is enabled, the emulator sometimes freezes, with an
error message in logcat similar to the following:

 QemuPipeStream::readFully failed (buf 0x7f9cd8ab8000): Bad address

Some users have reported the same issue, e.g.:

 https://code.google.com/p/android/issues/detail?id=170633

The root cause is that QemuPipeStream::readFully(void *buf, size_t len)
may attempt to read beyond (buf + len), resulting in a -EFAULT return
value from the goldfish/qemu pipe driver.

Fix this bug to improve the stability of the emulator. In addition,

 - Add more information to the said error message to facilitate future
   debugging.
 - Use "%zu" instead of "%d" for logging size_t variables.

Change-Id: I8785fee0427fd6c0f25237470b346e769a82c992
Signed-off-by: Yu Ning <yu.ning@intel.com>
Signed-off-by: Pengcheng Chen <pengcheng.chen@intel.com>
1 file changed