]> xenbits.xensource.com Git - libvirt.git/commitdiff
virPerfReadEvent: Prefer saferead over read
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 31 Mar 2016 14:43:08 +0000 (16:43 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 31 Mar 2016 15:25:21 +0000 (17:25 +0200)
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 <mprivozn@redhat.com>
src/util/virperf.c

index 9dc4e2562fea998f90fb608d64582cb5419f6eae..359a9c34ea0d0f2428554f1fe927d411184ac3a3 100644 (file)
@@ -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;