From: Long YunJian <long.yunjian@zte.com.cn> <br /> <br />If fscanf execute failed, qemuGetProcessInfo shuld return -1,<br />but it return 0 at the end. Zero means success for the caller,<br />so we shuld return -1 in the case of failure.<br /> <br />Signed-off-by: Long YunJian <long.yunjian@zte.com.cn> <br />Signed-off-by: Yi Wang <wang.yi59@zte.com.cn> <br />---<br /> src/qemu/qemu_driver.c | 8 ++++++--<br /> 1 file changed, 6 insertions(+), 2 deletions(-)<br /> <br />diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c<br />index df44c3fbd0..4c3785fa36 100644<br />--- a/src/qemu/qemu_driver.c<br />+++ b/src/qemu/qemu_driver.c<br />@@ -1442,11 +1442,13 @@ qemuGetProcessInfo(unsigned long long *cpuTime, int *lastCpu, long *vm_rss,<br />         return -1;<br />  <br />     pidinfo = fopen(proc, "r");<br />+    if (!pidinfo) {<br />+        return -1;<br />+    }<br />  <br />     /* See 'man proc' for information about what all these fields are. We're<br />      * only interested in a very few of them */<br />-    if (!pidinfo ||<br />-        fscanf(pidinfo,<br />+    if (fscanf(pidinfo,<br />                /* pid -> stime */<br />                "%*d (%*[^)]) %*c %*d %*d %*d %*d %*d %*u %*u %*u %*u %*u %llu %llu" <br />                /* cutime -> endcode */<br />@@ -1455,6 +1457,8 @@ qemuGetProcessInfo(unsigned long long *cpuTime, int *lastCpu, long *vm_rss,<br />                "%*u %*u %*u %*u %*u %*u %*u %*u %*u %*u %*d %d",<br />                &usertime, &systime, &rss, &cpu) != 4) {<br />         VIR_WARN("cannot parse process status data");<br />+        VIR_FORCE_FCLOSE(pidinfo);<br />+        return -1;<br />     }<br />  <br />     /* We got jiffies<br />--  <br />2.18.1<br />