From: Michal Privoznik Date: Thu, 31 Mar 2016 14:43:08 +0000 (+0200) Subject: virPerfReadEvent: Prefer saferead over read X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=2cbdd64adf8b5f3ad05fb7184ccb53f3c5172778;p=libvirt.git virPerfReadEvent: Prefer saferead over read Do I really need to explain why? Well, if read() is interrupted int the middle of reading, we will never read the rest (even though it's highly unlikely as we are reading just 8 bytes). Signed-off-by: Michal Privoznik --- diff --git a/src/util/virperf.c b/src/util/virperf.c index 9dc4e2562f..359a9c34ea 100644 --- a/src/util/virperf.c +++ b/src/util/virperf.c @@ -247,7 +247,7 @@ virPerfReadEvent(virPerfPtr perf, if (event == NULL || !event->enabled) return -1; - if (read(event->fd, value, sizeof(uint64_t)) < 0) { + if (saferead(event->fd, value, sizeof(uint64_t)) < 0) { virReportSystemError(errno, "%s", _("Unable to read cache data")); return -1;